代写AIC2100、代做Python编程语言
AIC2100 AI Programming with Python
Lab 6
Yonsei University
Lab 6 AIC2100
2
You must follow the specification thorougly!
• Any typos (including whitespace and linebreak) will result in a point deduction.
• If you’re asked to write the comment or docstring, you must add them.
• If some Python libraries are prohibited, importing them will result in 0 points.
• Depending on the lab content, additional rules can be added.
• Please read the specification document carefully and submit your code.
• We won't accept appeals for point deductions based on misinterpreting the lab specification
documentation.
• If any specification is unclear, please post your question on the Q&A board.
Lab 6 AIC2100
3
Please refer to the guidelines noted in previous labs. They remain applicable for this and
subsequent labs.
Any updates in guidelines will be announced again.
Coding guideline
Lab 6 AIC2100
4
Notation
• To clearly instruct the lab specifications, (1) we use “˽” to depict a whitespace (blank)
character and (2) “¤” for a “\n” (newline) character.
• Underlined text refers to the user input. -> input()
• New notations will be demonstrated additionally on there first mention.
Lab 6 AIC2100
5
Importing modules/libraries
You may be asked or permitted to use some specific modules/libraries. You are allowed to use
only specified ones in each problem. For example, if math module is mentioned in problem 1 but
not in problem 2, you are not allowed to use math module in problem 2.
Some custom modules may be required to use in the implementation. We will provide such
module python codes via LearnUs if necessary.
Lab 6 AIC2100
6
Class
In this lab, you will be asked to implement class. If you are asked to implement
the class only, you should not include the main program in your code, just like
the function.
Unexpected execution of the main program during the grading can result in 0
points, so please be careful!!
Lab 6 AIC2100
7
Class Docstring
You must put the docstring inside the class itself and all class methods, just
like you did in the function.
• 10 points will be deducted per lab problem with missing or insufficient docstrings.
• Don't forget to fill in the docstrings in the provided template code, too!
• Each docstring must be written in English and contain at least 20 characters.
class MyClass:
"""Class docstring"""
def __init__(self):
"""Method docstring"""
(your code continues…)
def method1(self, a, b):
"""Method docstring"""
(your code continues…)
Lab 6 AIC2100
8
[Recap] Marking Rule : Comments
• 10 points will be deducted per lab problem with missing or insufficient comments.
• Please put brief comments (#...) with all your code (including functions).
• You must include at least two comments in your code.
• Each comment must be at least 10 characters long and written in English.
Lab 6 AIC2100
9
[Recap] Marking Rule : Docstrings
• 10 points will be deducted per lab problem with missing or insufficient docstrings in all
functions.
• Please provide docstrings with all functions.
• Each function must include at least one docstring.
• Each docstring must be written in English and contain at least 20 characters.
• A docstring should briefly explain :
• The purpose of each parameter (if any).
• What the function computes.
• What the function returns to the caller (if anything).
def your_function(*your_args):
"""Your docstring"""
(your code continues…)
Lab 6 AIC2100
10
Comment vs Docstring in Function
• If you execute the following code,
• …here’s the result.
• They are different! Be careful not to confuse them.
• Docstring is a “string variable”.
• Comment is not a variable.
Lab 6 AIC2100
11
Programming Problems: Function
In some programming problems, you will be asked to implement a function. To solve such problems, you
must read the problem specification to understand:
1. What is the name of the asked function?
2. What input(s) does the asked function receive?
3. What should the function compute?
4. What should the function return?
▪ Unless requested in the problem specification, in your function you should not read input from the user,
and you should not print the results of your function!
▪ To test your function, you must write your own main program, which must call your function with
appropriate input values. In the main program, you can then print the value(s) returned from your
function to check for correctness.
• Do not hand in such a main program that you used to test your function!
• Only the function itself must be handed in.
Lab 6 AIC2100
12
Programming Problems: Function
Here’s an example. Assume that you are asked to implement a function my_add that takes two
numbers as parameters and returns their addition.
This is the correct program.
This is the incorrect program.
1. Wrong function name → No point
2. Wrong parameter input → No point
3. Missing docstring → 10 points deduction
4. Including print (or any implementation not requested in the lab
specification) in the main program part → No point
Lab 6 AIC2100
13
Problem 1
Fashion-MNIST is a dataset of Zalando's article images—consisting of a training set of 60,000 examples and
a test set of 10,000 examples. Each example is a 28 x 28 grayscale image, associated with a label from 10
classes.
Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms. Han Xiao, Kashif Rasul, Roland Vollgraf. arXiv:1708.07747
Lab 6 AIC2100
14
Problem 1
Labels
Each training and test example is assigned to one of the following labels:
0. T-shirt/top 1. Trouser 2. Pullover
3. Dress 4. Coat 5. Sandal
6. Shirt 7. Sneaker 8. Bag
9. Ankle boot
Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms. Han Xiao, Kashif Rasul, Roland Vollgraf. arXiv:1708.07747
Lab 6 AIC2100
15
Problem 1
Write a classifier model code to classify clothes using the given Fashion MNIST dataset and Pytorch.
The files you need to submit are as follows:
1. Training script (File name must be “lab6_p1.py”)
We have provided a basic skeleton code to LearnUs. Complete and extend the provided LearnUs skeleton
code to include all parts necessary to train your model (see next slide for details).
2. Trained weights (.pth file, File name must be “lab6_p1.pth”)
You must also submit the weights trained based on the code. Scoring is done based on (1) the weights and
(2) the model structure of the code you wrote, and you will be given a score based on whether 12 new
clothing data are correctly classified (see slide 21 for details).
Lab 6 AIC2100
16
Problem 1
1. Set network
In this section, write code to define and instantiate the layers of your neural
network with appropriate input and output dimensions.
2. Initialize weight (if needed)
Here, add code to apply a weight initialization scheme to each learnable layer
before training.
3. Set activation function
In this part, specify the activation functions that should follow your layers.
4. Set model
Combine your previously defined layers and activations into a single model
container and move it to the chosen device with .to method.
5. Set loss and optimizer
Write code to choose a loss function and instantiate an optimizer using your
model’s parameters.
Lab 6 AIC2100
17
Problem 1
train
In this stage, the model learns patterns
by repeatedly processing the training
data, comparing its predictions to the
true labels, and adjusting its internal
parameters to reduce errors. Through
this iterative optimization, the network’s
weights are refined so that its outputs
become increasingly accurate.
Lab 6 AIC2100
18
Problem 1
eval
In this phase, the model is set to
inference mode and processes a single
input image to produce a set of class
scores. It then selects and returns the
class with the highest score as its final
prediction, without altering any model
parameters.
Lab 6 AIC2100
19
Problem 1
Generate trainer: Instantiates FashionMNIST Trainer, setting random seed,
device, data loaders, and model skeleton.
Run train: Executes the training loop to optimize the model’s weights on the
FashionMNIST training set.
Evaluate on test set: Computes and prints overall accuracy of the trained model
on the test dataset.
Pick a sample and predict: Randomly selects one test image and its true label,
runs it through eval(), and prints both the actual label and the model’s predicted
label.
Export model: Saves the current model’s learned weights to a file (lab6_p1.pth).
Import model: Loads the saved weights back into the model to restore its state.
Re-evaluate on test set: Runs eval_all() again to confirm the imported weights
yield the same test accuracy as before.
Lab 6 AIC2100
20
Problem 1
Note 1. Do not change the seed value (2025) in the code! We will check whether the weights you
submit are derived from the code you actually wrote. This is used to check for plagiarism.
Note 2. The recommended versions of the libraries provided are as follows (latest versions as of
2025/05):
numpy ==2.2.5
torch==2.7.0
torchvision==0.22.0
matplotlib==3.10.3
Lab 6 AIC2100
21
Problem 1
Note 3.
This Lab6 Problem1 is scored in the following guide.
1. There are 12 clothing images that are not in the Fashion MNIST dataset.
2. We will classify the 12 images using your submitted model and code.
3. [1] Whether the image was classified correctly and [2] the classification accuracy are evaluated, and up to 6-7
points are given per image. (Since there are 12 images, the total score is 80 points.)
4. Once you have submitted your code and model to Gradescope, you can view the scores for the 12 images. If
you’re not satisfied with your scores, you may retrain your model and resubmit both your code and model.
Note 4.
Do not use different data for model train and test! (Even if it is the Fashion MNIST dataset)
Lab 6 AIC2100
22
Marking Criteria
• Score is only given to programs that compile and produce the correct output with Python version
3.
• No points for programs that are named wrongly. Please refer to the following slide for the
required file names.
• Points are deducted for programs that produce warnings.
• Please pay particular attention to the requested output format of your programs. Deviating from
the requested output format results in points deductions.
• Gradescope only allows code to run for up to 10 minutes!
• If your code takes longer than 10 minutes to execute due to excessive computation, it will not be
graded and will be marked as incorrect.
• (10 minutes is a very generous limit for this Lab assignment, but please still pay attention to the
efficiency of your code.)
Lab 6 AIC2100
23
Plagiarism
• Plagiarism (Cheating)
– This is an individual assignment. All or some submissions are checked for plagiarism.
• We will not inform you which problems will be checked.
– Once detected, measures will be taken for all students involved in the plagiarism incident
(including the "source'' of the plagiarized code).
Lab 6 AIC2100
24
Please prepare the files for the programming problems. The names of the files, their due dates, and the
archive file names are given in the table above.
• Please upload your file by the stated due date on Gradescope.
• Please pay attention to file names.
Deliverables, Due Date and Submission
Problem File name Due
1
lab6_p1.py
lab6_p1.pth
Friday
June 6, 2025,
23:59

热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图