首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写data编程、Python编程设计代做
项目预算:
开发周期:
发布时间:
要求地区:
Assignment 1
Deadline: 10.24.2023 - 11.59pm
By the deadline, you are required to submit the following:
Report. Prepare a single PDF file that presents clear and concise evidence of
your completion of each of the listed tasks. Use the overleaf template available on iCorsi.
Source code. Create a single zipped Python script using the template available on iCorsi, performing each of the specified tasks. If a task is accomplished
in the code but not documented in the report, it will be considered incomplete.
Therefore, make sure to thoroughly report all your work in the submitted report. Jupyter notebook files will not be accepted.
General hints. The question marked with * is more challenging, and we recommend possibly leaving them as the last questions to solve. To obtain the
maximum grade, not only should all exercises be completed correctly, but the
plots must also be clear, have a legend, and have labels on the axes and the
text should be written in clear English. For saving plots in high quality, consider using the command matplotlib.pyplot.savefig. Clarity of plots
and text will account in total for 5 points.
Submission rules: As already discussed in class, we will stick to the following rules.
• Submit ONE pdf file containing your report and ONE (zipped) .py file
containing the code. Use the templates and name your files
NAME SURNAME.pdf and NAME SURNAME.py. We will read and
correct only these files. Other files present in the folder will not be read.
If such files are missing, they will be evaluated with a score of 0.
• Code either not written in Python or not using PyTorch receives a grade
of 0. Of course you can use auxiliary packages when needed (matplotlib,
numpy,. . . ), but for the learning part, you must use PyTorch.
• Submission between 00.00am - 00.10 of Wednesday 25th will be accepted
with no reduction.
• If plagiarism is suspected, TAs and I will thoroughly investigate the situation, and we will summon the student for a face-to-face clarification
regarding certain answers they provided. In case of plagiarism, a score
1
reduction will be applied to all the people involved, depending on their
level of involvement.
• If extensive usage of AI tools is detected, we will summon the student
for a face-to-face clarification regarding certain answers they provided.
If the answers are not adequately supported with in-person answers, we
will proceed to apply a penalty to the evaluation, ranging from 10% to
100%.
Polynomial regression (with gradient descent) [95 points]
Let z ∈ R and consider the polynomial
p(z) = z
4
100
− z
3 + z
2 − 10z =
X
4
k=1
z
kwk (1)
where w = [w1, w2, w3, w4]
T = [−10, 1, −1,
1
100 ]
T
. This polynomial can be also
expressed as the dot product of two vectors, namely
p(z) = wT x x = [z, z2
, z3
, z4
]
T
(2)
Consider an independent and identically distributed (i.i.d.) dataset D = {(zi
, yi)}
N
i=1,
where yi = p(zi) + εi
, and each εi
is drawn from a normal distribution with
mean zero and standard deviation σ.
Now, assuming that the vector w is unknown, linear regression could estimate it using the dot-product form presented in Equation 2. To achieve this we
can move to another dataset
D
′
:= {(xi
, yi)}
N
i=1 x
i = [zi
, z2
i
, z3
i
, z4
i
]
T
The task of this assignment is to perform polynomial regression using gradient descent with PyTorch, even if a closed-form solution exists.
1. (5 pts) Define a function
plot_polynomial(coeffs, z_range, color=’b’)
Where coeffs is a np.array containing [w0, w1, w2, w3, w4]
T
(w0 in this
case is equal to 0) z_range is the interval [zmin, zmax] of the z variable;
color represent a color. Use the function to plot the polynomial. Report
and comment on the plot.
2. (10 pts) Write a function
create_dataset(coeffs, z_range, sample_size, sigma, seed=42)
that generates the dataset D′
. Here coeffs is a np.array containing
[w0, w1, w2, w3, w4]
T
, z_range is the interval [zmin, zmax] of the z variable;
sample_size is the dimension of the sample; sigma is the standard
deviation of the normal distrbution from which εi are sampled; seed is
the seed for the random procedure.
2
3. (5 pts) Use the code of the previous point to generate data with the following parameters
• Each zi should be in the interval [−3, 3]
• σ = 0.5
• Use a sample size of 500 for training data and a seed of 0
• Use a sample size of 500 for evaluation data and a seed of 1
4. (5 pts) Define a function
visualize_data(X, y, coeffs, z_range, title="")
that plot the polynomial p(z) and the generated data, (train and evaluation), where X, y are as returned from the function create_dataset,
coeffs are the coefficient of the polynomial, z_range is the interval
[zmin, zmax] of the z variable and title may be helpful to distinguish between the training and the evaluation plots. What we mean with this
question, is the following: Provide two plots containing both the true
polynomial; In one, add a scatter plot with the training data, and in the
other a scatter plot with the evaluation data. Use the function to visualize
the data. Report and comment on the plots.
5. (20 pts) Perform polynomial regression on D using linear regression on
D′ and reports some comments on the training procedure. Consider your
training procedure good when the training loss is less than 0.5. This
works in my code with a number of steps equal to 3000. In particular,
explain:
• How you preprocessed the data.
• Which learning rate do you use, and why. What happens if the
learning rate is too small; what happens if the learning rate is too
high, and why.
• If bias should be set as True of False in torch.nn.Linear and
why.
You should use the data you generated at point 3. Note: If you plan to reuse code explained during the lecture, explicitly indicate which parts are
being reused or readjusted/modified. In any case, the steps must always
be explained and understood in detail.
6. (10 pts) Plot the training and evaluation loss as functions of the iterations
and report them in the same plot. If you use both steps and epochs, you
can choose either of the two, as long as it is clear from the plot and the
plot reports what we expect - namely, that the loss functions decrease.
7. (5 pts) Plot the polynomial you got with your estimated coefficient as
well as the original one in the same plot.
3
8. (10 pts) Plot the value of the parameters at each iteration as well as the
true value. What we expect is a plot having on the x axis the number of
steps/epochs and on the y axis the value of the parameters while they
are learned. Then, in the same graph, plot a horizontal line with the true
value.
9. (15 pts) Re-train the model with the following parameters:
• Each zi should be in the interval [−3, 3]
• σ = 0.5
• Use a sample size of 10 for training data and a seed of 0
• Use a sample size of 500 for evaluation data and a seed of 1
• Keep the learning rate you chose at the previous point.
Report: A plot with both the training and evaluation loss as functions of
the iterations in the same plot and the polynomial you got with your estimated coefficient as well as the original one in the same plot. Comment
on what is going on. Note: Do not overwrite the code, keep the original
training and this new one as two separate parts.
10. (5 pts*) This part is less trivial and should be considered as a separate
exercise. Suppose you have to learn the function
f(x) = 5 sin(x) + 3
and you know that your data are x
i belong to the interval [−a, a]. Which
performances would you expect using linear regression in the following
cases?
(a) a = 0.01
(b) a = 5
Note: We want to see some code that generates noisy data from f, do the
linear regression and we want to see the loss value on it. If you know
the mathematics behind it, you can use your knowledge to answer and
validate the data, but as this is a Lab exam, we want to see empirical
evidence.
Questions [5 points]
Please answer these questions in max 10 lines. In Lecture 3, we have seen an
explicit step of the parameter update for one-dimensional linear regression,
namely
wt+1 = wt − α
∂L
∂w (wt, bt) (3)
bt+1 = bt − α
∂L
∂b (wt, bt) (4)
Hint: Do we have any information about the gradient of the loss function with
respect to the parameter at the very beginning of the training loop?
4
(a) Do you think that could be beneficial to choose two different values of α
(learning rate) for Equation (3) and (4)?
(b) Explain the difference between choosing two different learning rates in
principle and what is instead done by the adaptive methods - e.g, Adagrad. If you don’t know the method, you can study one of the following
resources:
• Section 8.5.1 of Deep Learning Book
• Section 12.7 of Dive Into Deep Learning
5
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
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
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!