首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CEG5301代做、MATLAB编程语言代写
项目预算:
开发周期:
发布时间:
要求地区:
CEG5301 Machine Learning with Applications:
Part I: Homework #3
Important note: the due date is 17/03/2024. Please submit the softcopy of your report
to the submission folder in CANVAS. Late submission is not allowed unless it is well
justified. Please supply the MATLAB code or Python Code in your answer if computer
experiment is involved.
Please note that the MATLAB toolboxes for RBFN and SOM are not well developed.
Please write your own codes to implement RBFN and SOM instead of using the
MATLAB toolbox.
Q1. Function Approximation with RBFN (10 Marks)
Consider using RBFN to approximate the following function:
𝑦𝑦 = 1.2 sin(𝜋𝜋𝜋𝜋) − cos(2.4𝜋𝜋𝜋𝜋) , 𝑓𝑓𝑓𝑓𝑓𝑓 𝑥𝑥 ∈ [−1.6, 1.6]
The training set is constructed by dividing the range [−1.6, 1.6] using a uniform step
length 0.08, while the test set is constructed by dividing the range [−1.6, 1.6] using
a uniform step length 0.01. Assume that the observed outputs in the training set are
corrupted by random noise as follows.
𝑦𝑦(𝑖𝑖) = 1.2 sin 𝜋𝜋𝜋𝜋(𝑖𝑖) − cos 2.4𝜋𝜋𝜋𝜋(𝑖𝑖) + 0.3𝑛𝑛(𝑖𝑖)
where the random noise 𝑛𝑛(𝑖𝑖) is Gaussian noise with zero mean and stand deviation of
one, which can be generated by MATLAB command randn. Note that the test set is not
corrupted by noises. Perform the following computer experiments:
a) Use the exact interpolation method (as described on pages 17-26 in the slides of
lecture five) and determine the weights of the RBFN. Assume the RBF is Gaussian
function with standard deviation of 0.1. Evaluate the approximation performance of
the resulting RBFN using the test set.
(3 Marks)
b) Follow the strategy of “Fixed Centers Selected at Random” (as described on page 38
in the slides of lecture five), randomly select 20 centers among the sampling points.
Determine the weights of the RBFN. Evaluate the approximation performance of the
resulting RBFN using test set. Compare it to the result of part a).
(4 Marks)
c) Use the same centers and widths as those determined in part a) and apply the
regularization method as described on pages 43-46 in the slides for lecture five. Vary
the value of the regularization factor and study its effect on the performance of RBFN.
(3 Marks)
2
Q2. Handwritten Digits Classification using RBFN (20 Marks)
In this task, you will build a handwritten digits classifier using RBFN. The training data
is provided in MNIST_M.mat. Each binary image is of size 28*28. There are 10
classes in MNIST_M.mat; please select two classes according to the last two different
digits of your matric number (e.g. A0642311, choose classes 3 and 1; A1234567,
choose classes 6 and 7). The images in the selected two classes should be assigned the
label “1” for this question’s binary classification task, while images in all the remaining
eight classes should be assigned the label “0”. Make sure you have selected the correct
2 classes for both training and testing. There will be some mark deduction for wrong
classesselected. Please state your handwritten digit classes for both training and testing.
In MATLAB, the following code can be used to load the training and testing data:
-------------------------------------------------------------------------------------------------------
load mnist_m.mat;
% train_data training data, 784x1000 matrix
% train_classlabel the labels of the training data, 1x1000 vector
% test_data test data, 784x250 matrix
% train_classlabel the labels of the test data, 1x250 vector
-------------------------------------------------------------------------------------------------------
After loading the data, you may view them using the code below:
-------------------------------------------------------------------------------------------------------
tmp=reshape(train_data(:,column_no),28,28);
imshow(tmp);
-------------------------------------------------------------------------------------------------------
To select a few classes for training, you may refer to the following code:
-------------------------------------------------------------------------------------------------------
trainIdx = find(train_classlabel==0 | train_classlabel==1 | train_classlabel==2); % find the
location of classes 0, 1, 2
Train_ClassLabel = train_classlabel(trainIdx);
Train_Data = train_data(:,trainIdx);
-------------------------------------------------------------------------------------------------------
Please use the following code to evaluate:
-------------------------------------------------------------------------------------------------------
TrAcc = zeros(1,1000);
TeAcc = zeros(1,1000);
thr = zeros(1,1000);
TrN = length(TrLabel);
TeN = length(TeLabel);
for i = 1:1000
t = (max(TrPred)-min(TrPred)) * (i-1)/1000 + min(TrPred);
thr(i) = t;
TrAcc(i) = (sum(TrLabel(TrPred
=t)==1)) / TrN;
TeAcc(i) = (sum(TeLabel(TePred
=t)==1)) / TeN;
end
3
plot(thr,TrAcc,'.- ',thr,TeAcc,'^-');legend('tr','te');
-------------------------------------------------------------------------------------------------------
TrPred and TePred are determined by TrPred(j) = ∑ 𝑤𝑤𝑖𝑖𝜑𝜑𝑖𝑖(TrData(: , j)) 𝑁𝑁
𝑖𝑖=0 and
TePred(j) = ∑ 𝑤𝑤𝑖𝑖𝜑𝜑𝑖𝑖(TeData(: , j)) 𝑁𝑁
𝑖𝑖=0 where 𝑁𝑁 is the number of hidden neurons.
TrData and TeData are the training and testing data selected based on your matric
number. TrLabel and TeLabel are the ground-truth label information (Convert to {0,1}
before use!).
You are required to complete the following tasks:
a) Use Exact Interpolation Method and apply regularization. Assume the RBF is
Gaussian function with standard deviation of 100. Firstly, determine the weights of
RBFN without regularization and evaluate its performance; then vary the value of
regularization factor and study its effect on the resulting RBFNs’ performance.
(6 Marks)
b) Follow the strategy of “Fixed Centers Selected at Random” (as described in page 38
of lecture five). Randomly select 100 centers among the training samples. Firstly,
determine the weights of RBFN with widths fixed at an appropriate size and compare
its performance to the result of a); then vary the value of width from 0.1 to 10000 and
study its effect on the resulting RBFNs’ performance.
(8 Marks)
c) Try classical “K-Mean Clustering” (as described in pages 39-40 of lecture five) with
2 centers. Firstly, determine the weights of RBFN and evaluate its performance; then
visualize the obtained centers and compare them to the mean of training images of each
class. State your findings.
(6 Marks)
4
Q3. Self-Organizing Map (SOM) (20 Marks)
a) Write your own code to implement a SOM that maps a 1-dimensional output layer
of 40 neurons to a “hat” (sinc function). Display the trained weights of each output
neuron as points in a 2D plane, and plot lines to connect every topological adjacent
neurons (e.g. the 2nd neuron is connected to the 1st and 3rd neuron by lines). The training
points sampled from the “hat” can be obtained by the following code:
-------------------------------------------------------------------------------------------------------
x = linspace(-pi,pi,400);
trainX = [x; sinc(x)]; 2x400 matrix
plot(trainX(1,:),trainX(2,:),'+r'); axis equal
-------------------------------------------------------------------------------------------------------
(3 Marks)
b) Write your own code to implement a SOM that maps a 2-dimensional output layer
of 64 (i.e. 8×8) neurons to a “circle”. Display the trained weights of each output neuron
as a point in the 2D plane, and plot lines to connect every topological adjacent neurons
(e.g. neuron (2,2) is connected to neuron (1,2) (2,3) (3,2) (2,1) by lines). The training
points sampled from the “circle” can be obtained by the following code:
-------------------------------------------------------------------------------------------------------
X = randn(800,2);
s2 = sum(X.^2,2);
trainX = (X.*repmat(1*(gammainc(s2/2,1).^(1/2))./sqrt(s2),1,2))'; 2x800 matrix
plot(trainX(1,:),trainX(2,:),'+r'); axis equal
-------------------------------------------------------------------------------------------------------
(4 Marks)
c) Write your own code to implement a SOM that clusters and classifies handwritten
digits. The training data is provided in Digits.mat. The dataset consists of images in 5
classes, namely 0 to 4. Each image with the size of 28*28 is reshaped into a vector and
stored in the Digits.mat file. After loading the mat file, you may find the 4 matrix/arrays,
which respectively are train_data, train_classlabel, test_data and test_classlabel. There
are totally 1000 images in the training set and 100 images in the test set. Please omit 2
classes according to the last digit of your matric number with the following rule:
omitted class1 = mod(the last digit, 5), omitted_class2 = mod(the last digit+1, 5). For
example, if your matric number is A0642347, ignore classes mod(7,5)=2 and
mod(8,5)=3; A1234569, ignore classes 4 and 0.
Thus, you need to train a model for a 3-classes classification task. Make sure you have
selected the correct 3 classes for both training and testing. There will be some mark
deduction for wrong classes selected. Please state your handwritten digit classes for
both training and testing.
After loading the data, complete the following tasks:
c-1) Print out corresponding conceptual/semantic map of the trained SOM (as
described in page 24 of lecture six) and visualize the trained weights of each output
neuron on a 10×10 map (a simple way could be to reshape the weights of a neuron
5
into a 28×28 matrix, i.e. dimension of the inputs, and display it as an image). Make
comments on them, if any.
(8 Marks)
c-2) Apply the trained SOM to classify the test images (in test_data). The
classification can be done in the following fashion: input a test image to SOM, and
find out the winner neuron; then label the test image with the winner neuron’s label
(note: labels of all the output neurons have already been determined in c-1).
Calculate the classification accuracy on the whole test set and discuss your
findings.
(5 Marks)
The recommended values of design parameters are:
1. The size of the SOM is 1×40 for a), 8×8 for b), 10×10 for c).
2. The total iteration number N is set to be 500 for a) & b), 1000 for c). Only the
first (self-organizing) phase of learning is used in this experiment.
3. The learning rate 𝜂𝜂(𝑛𝑛) is set as:
𝜂𝜂(𝑛𝑛) = 𝜂𝜂0 exp − 𝑛𝑛
𝜏𝜏2
, 𝑛𝑛 = 0,1,2, …
where 𝜂𝜂0 is the initial learning rate and is set to be 0.1, 𝜏𝜏2 is the time constant
and is set to be N.
4. The time-varying neighborhood function is:
ℎ𝑗𝑗,𝑖𝑖(𝑥𝑥)(𝑛𝑛) = exp − 𝑑𝑑𝑗𝑗,𝑖𝑖
2
2𝜎𝜎(𝑛𝑛)2 , 𝑛𝑛 = 0,1,2, …
where 𝑑𝑑𝑗𝑗,𝑖𝑖 is the distance between neuron j and winner i, 𝜎𝜎(𝑛𝑛) is the effective
width and satisfies:
𝜎𝜎(𝑛𝑛) = 𝜎𝜎0 exp − 𝑛𝑛
𝜏𝜏1
, 𝑛𝑛 = 0,1,2, …
where 𝜎𝜎0 is the initial effective width and is set according to the size of output
layer’s lattice, 𝜏𝜏1 is the time constant and is chosen as 𝜏𝜏𝑖𝑖 = 𝑁𝑁
log(𝜎𝜎0)
.
Again, please feel free to experiment with other design parameters which may be
different from the given ones.
软件开发、广告设计客服
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
软件定制开发网!