我试图在MATLAB上实现“静态梯度设计”。 我完全遵循算法,但得到了非常大的w(coffients )预测/拟合函数。 算法有错误吗? 随机梯度下降实无情的金毛/p
x=0:0.1:2*pi //X-axis
n=size(x,2 );
r=-0.2(0.4 ).*rand(n,1 ); //generatingrandomnoisetobeaddedtothesin (x ) function
t=Zeros(1,n );
for i=1:n
t(I )=sin ) x ) I ) ) r ) I; //adding the noise
结束
f=round(1rand ) 20,1 ) *n ); //generating random indexes
h=x(f ); //choosing random x points
k=t(f ); //chossing random y points
m=size(h,2 ); //length of the h vector
scatter(h,k,' Red ' ); //drawingthetrainingpoints (with noise ) )。
%scatter(x,t,2 );
保持打开;
plot(x,sin ) x ); //plotting the Sin function
a=0.05; //learning rate 'alpha '
//------------- algorithm-------/
for i=1:20
v=[1h(I ) h ) I ).^2]; //X vector
e=() w*v ) )-k ) I ) ) . //prediction - observation
结束
保持打开;
l=0:1:6;
g=w(1) w )2) Lw )3) ) *(l.^2;
plot(L,g,' Yellow ' ); //drawing the prediction function
2011-02-25