funding 发表于 2008-10-23 12:24

[求助]神经网络权值成了NAN怎么解决

%程序为BP神经网络PID,
clear all;
close all;
ts=20;
sys=tf(,,'inputdelay',80);
dsys=c2d(sys,ts ,'zoh');
=tfdata(dsys,'v'); %将传递函数G(s)=e-80s/60s+1离散化
xite=0.25;
alfa=0.05;
in=4;h=5;out=3;
wi=rands(h,in);
wi1=wi;wi2=wi;wi3=wi;
wi
wo=rands(out,h);
wo1=wo;wo2=wo;wo3=wo;
wo
x=;
u1=0;u2=0;u3=0;u4=0;u5=0;
y1=0;y2=0;y3=0;
oh=zeros(h,1);I=oh;
e1=0;e2=0;
for k=1:1:200
time(k)=k*ts;
r(k)=40;
y(k)=-den(2)*y1+num(2)*u5;
e(k)=r(k)-y(k);
xi=;
x1=e(k)-e1;
x2=e(k);
x3=e(k)-2*e1+e2;
epid=;
I=xi*wi';
for j=1:1:h
oh(j)=(exp(I(j))-exp(-I(j)))/(exp(I(j))+exp(-I(j)));
end
KI=wo*oh;
for t=1:1:out
hy(t)=exp(KI(t))/(exp(KI(t))+exp(-KI(t)));
end
kp=hy(1);ki=hy(2);kd=hy(3);
kpid=;
du(k)=epid*kpid';
u(k)=u1+du(k);
if(u(k)>=110)
u(k)=110;
end
if(u(k)<=-110)
u(k)=-110;
end
dyu(k)=sign((y(k)-y1)/(u(k)-u1+0.00001));
for j=1:1:out
   dk(j)=2/(exp(hy(j))+exp(-hy(j)))^2;
end
for t=1:1:out
delta3(t)=e(k)*dyu(k)*epid(t)*dk(t);
end
for j=1:1:out
for i=1:1:h
dwo=xite*delta3(j)*oh(i)+alfa*(wo1-wo2);
end
end
wo=wo1+dwo+alfa*(wo1-wo2);
wo
for(i=1:1:h)
do(i)=4/(exp(I(i))+exp(-I(i)))^2;
end
segma=delta3*wo;
for(i=1:1:h)
delta2(i)=do(i)*segma(i);
end
dwi=xite*delta2'*xi;
wi=wi1+dwi+alfa*(wi1-wi2);
wi
u5=u4;u4=u3;u3=u2;u2=u1;u1=u(k);
y3=y2;y2=y1;y1=y(k);
wo3=wo2;
wo2=wo1;
wo1=wo;
wi3=wi2;
wi2=wi1;
wi1=wi;
e2=e1;
e1=e(k);
end

plot(time, r,'r',time,y,'b');
xlabel('time(s)');ylabel('rin,yout');


这是程序,运行后的得到的图像就只有一部分,输出权值全是NAN,
当把输入信号改为r(k)=1,输出的U限制在[-1010]之间,就可以出来完整的图像
请高手给看一下,问题到底出在哪里,怎么解决。

[ 本帖最后由 xmwhit 于 2008-10-27 17:04 编辑 ]
页: [1]
查看完整版本: [求助]神经网络权值成了NAN怎么解决