bp网络训练演示

bp网络训练演示





%bp网络训练演示 %初始值 P=-1:0.1:1; %目标值 T=[0:0.314:6.28]; T=sin(T); %%创建两层前向回馈网络 net=newcf(minmax(P),[5,1],{'tansig','purelin'},'traingd'); % 初始化网络 net = initnw(net,1); % initnw is a layer initialization function % that initializes a layer's weights and biases % according to the Nguyen-Widrow initialization algorithm. % This algorithm chooses values in order to distribute % the active region of each neuron in the layer approximately evenly across the layer's input space. % initnw(net,i) takes two arguments, % net -- Neural network % i -- Index of a layer % and returns the network with layer i's weights and biases updated. w0 = net.iw{1,1}; b0 = net.b{1}; w1 = net.lw{2,1}; b1 = net.b{2}; %仿真,模拟结果 y=sim(net,P); %初始值,目标值 plot(P,T,'ro') hold on %画出初始目标值 plot(P,y) hold off %初始化训练参数 net.trainParam.epochs=7000; net.trainParam.goal=9.5238e-004; net.iw{1,1}=w0*0.5; net.b{1}=b0*0.5; net.trainParam.lr = 0.15; %训练网络 [net tr]=train(net,P,T); %计算结果 Y=sim(net,P); %画出最后的训练结果 figure(2) plot(P,T,'ro') hold on plot(P,Y) hold off

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值