?? bp5.m
字號:
%bp5;例4.5
%
time=[];err=[];epo=[];
for i=1:6 %分別進(jìn)行取S1= 1 - 6節(jié)點時的網(wǎng)絡(luò)訓(xùn)練
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' );
%創(chuàng)建兩層前向BP網(wǎng)絡(luò)
net.trainParam.show = 50; %每50次顯示一次結(jié)果
net.trainParam.lr = 0.05; %學(xué)習(xí)參數(shù)
net.trainParam.epochs = 300; %最大循環(huán)參數(shù)
[net,tr]=train(net,P,T); %訓(xùn)練網(wǎng)絡(luò)
Y=sim(net,P); %計算輸出結(jié)果
err=[err;tr.perf];
time(i)=cputime-t(i); %計算程序運行時間
end
plot(err(1,:)); %做出以上6個網(wǎng)絡(luò)的訓(xùn)練誤差圖
hold on
plot(err(2,:),'g:');
plot(err(3,:),'g-');
plot(err(4,:),':');
plot(err(5,:),'r:');
plot(err(6,:),'r-');
hold off
time
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -