?? bp5.m
字號:
%bp5;例4.5
%
time=[];err=[];epo=[];
for i=1:6 %分別進行取S1= 1 - 6節點時的網絡訓練
t(i)=cputime; %起始CPU時間
P=[0 0 1 1;0 1 0 1];
T=[0 1 1 0];
net=newcf(minmax(P),[i,1],{'tansig' 'purelin'},'traingd' );
%創建兩層前向BP網絡
net.trainParam.show = 50; %每50次顯示一次結果
net.trainParam.lr = 0.05; %學習參數
net.trainParam.epochs = 300; %最大循環參數
[net,tr]=train(net,P,T); %訓練網絡
Y=sim(net,P); %計算輸出結果
err=[err;tr.perf];
time(i)=cputime-t(i); %計算程序運行時間
end
plot(err(1,:)); %做出以上6個網絡的訓練誤差圖
hold on
plot(err(2,:),'g:');
plot(err(3,:),'g-');
plot(err(4,:),':');
plot(err(5,:),'r:');
plot(err(6,:),'r-');
hold off
time
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -