?? gafault.m
字號(hào):
% 用GA訓(xùn)練BP網(wǎng)絡(luò)的權(quán)值、閾值
tic, % 開始計(jì)時(shí)
[P,T,R,S1,S2,S]=nninit; % BP網(wǎng)絡(luò)初始化
aa=ones(S,1)*[-1 1];
popu=60; % 初始種群個(gè)數(shù)
initPpp=initializega(popu,aa,'gabpEval');
gen=700; % 遺傳代數(shù)
[x endPop bPop trace]=ga(aa,'gabpEval',[],initPpp,[1e-6 1 1],'maxGenTerm',gen,...
'normGeomSelect',[0.09],['arithXover'],[2],'nonUnifMutation',[2 gen 3]);
%%Lets take a look at the performance of the ga during the run
subplot(2,1,1)
plot(trace(:,1),1./trace(:,3),'r-')
hold on
plot(trace(:,1),1./trace(:,2),'b-')
xlabel('Generation');
ylabel('Sum-Squared Error');
subplot(2,1,2)
plot(trace(:,1),trace(:,3),'r-')
hold on
plot(trace(:,1),trace(:,2),'b-')
xlabel('Generation');
ylabel('Fittness');
% 從編碼x中解碼出BP網(wǎng)絡(luò)所對(duì)應(yīng)的權(quán)值、閾值
[W1 B1 W2 B2]=gadecod(x);
% 仿真結(jié)果
TT=simuff(P,W1,B1,'tansig',W2,B2,'purelin')
E=sum((T-TT).^2)./10;
E=sqrt(E)
e1=(T-TT)./T
c=poststd(TT,meant,stdt)
toc % 結(jié)束計(jì)時(shí)
xk1=input(' please input .....xk==')
pnew=xk1';
pnew=trastd(pnew,meanp,stdp);%將數(shù)據(jù)通過自標(biāo)準(zhǔn)化再用來輸入網(wǎng)絡(luò)
an=simuff(pnew,W1,B1,'tansig',W2,B2,'purelin')%網(wǎng)絡(luò)模擬出來的值
anew=poststd(an,meant,stdt)%模擬出的值再線性返回樣本預(yù)測值
tk1=input(' please input .....tk==')
e2=(tk1-anew)./tk1
xk2=input(' please input .....xk==')
pnew=xk2';
pnew=trastd(pnew,meanp,stdp);%將數(shù)據(jù)通過自標(biāo)準(zhǔn)化再用來輸入網(wǎng)絡(luò)
an=simuff(pnew,W1,B1,'tansig',W2,B2,'purelin')%網(wǎng)絡(luò)模擬出來的值
anew=poststd(an,meant,stdt)%模擬出的值再線性返回樣本預(yù)測值
tk2=input(' please input .....tk==')
e2=(tk2-anew)./tk2
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -