神经网络程序.docVIP

  • 9
  • 0
  • 约1.14千字
  • 约 3页
  • 2017-08-09 发布于重庆
  • 举报
神经网络程序.doc

k=1 p=[-1:.05:1] t=sin(k*pi*p) plot(p,t,-) title(要逼近的非线性函数) xlabel(时间) ylabel(非线性函数); n=10; net=newff(minmax(p),[n,1],{tansig purelin},trainlm); y1=sim(net,p); figure; plot(p,t,-,p,y1,-) ; title(未训练网络的输出结果); xlabel(时间); ylabel(仿真输出 - - 原函数 -); net.trainParam.epochs=50 net.trainParam.goal=0.01 net=train(net,p,t) y2=sim(net,p) figure; plot(p,t,-,p,y1, -,p,y2, -) ; title(训练后网络的输出结果); xlabel(时间); ylabel(仿真输出); p=[-1 -1 2 2;0 5 0 5]; t=[-1 -1 1 1]; net=newff(minmax(p),[3,1],{tansig,purelin},traingd) net.trainParam.show=50; net.trainParam.Ir=0.05; net.trainParam.epochs=300; net.trainParam.goal=1e-5; [net,tr]=train(net,p,t); k=2; n=10; p=[-1:.05:1] t=sin(k*pi*p) plot(p,t,-) title(要逼近的非线性函数) xlabel(时间) ylabel(非线性函数); net=newff(minmax(p),[n,1],{tansig purelin},trainlm); y1=sim(net,p); figure; plot(p,t,-,p,y1,- -) title(未训练网络的输出结果); xlabel(时间); ylabel(仿真输出 - - 原函数 -); net.trainParam.epochs=50; net.trainParam.goal=0.01; net=train(net,p,t); P=[0 1 2 3 4 5 6 7 8 9 10] T=[0 1 2 3 4 3 2 1 2 3 4] net=newff(P,T,5) Y=sim(net,p) plot(P,T,P,Y, 0)

文档评论(0)

1亿VIP精品文档

相关文档