how to plot this function?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
if true
% code
endfunction [finalW, MSE, Numiterations] = gradientDescentLinearNeuron(P, t, lr, ErrorGoal, MaxIterations)
FinalW=(2*rand(1,100)-1)/10;
x=(2*rand(1,100)-1)/10;
x(:);
ErrorGoal=0.15;
lr=0.1;
step=1;
while ((MSE>ErrorGoal)&&(step<=MaxIterations))
y1=FinalW*x;
si=size(FinalW);
y2=ones(si);
y=[y1,y2];
dMSEdw=-1/((length(x)*((sum(t)-y)*x)));
FinalW=FinalW-lr*dMSEdw;
MSE=1/2*(length(x)*((sum(t)-y).^2));
step=step+1;
end
end
3 Comments
madhan ravi
on 1 Nov 2018
P, t, lr, ErrorGoal, MaxIterations??
ariellewin11 ariellewin11
on 1 Nov 2018
Edited: ariellewin11 ariellewin11
on 1 Nov 2018
Kevin Chng
on 1 Nov 2018
function [finalW, MSE, Numiterations] = gradientDescentLinearNeuron(P, t, lr, ErrorGoal, MaxIterations)
FinalW=(2*rand(1,100)-1)/10;
x=(2*rand(1,100)-1)/10;
x(:);
ErrorGoal=0.15;
lr=0.1;
step=1;
while ((MSE>ErrorGoal)&&(step<=MaxIterations))
y1=FinalW*x;
si=size(FinalW);
y2=ones(si);
y=[y1,y2];
dMSEdw=-1/((length(x)*((sum(t)-y)*x)));
FinalW=FinalW-lr*dMSEdw;
MSE=1/2*(length(x)*((sum(t)-y).^2));
step=step+1;
end
end
What do you want to plot?
plot(Numiterations,finalW)
What is the error?
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!