資源簡(jiǎn)介
利用遺傳算法優(yōu)化神經(jīng)網(wǎng)絡(luò)的相關(guān)參數(shù),具有一定的實(shí)用性。
代碼片段和文件信息
%%%%%?利用GA優(yōu)化BP網(wǎng)絡(luò)的權(quán)值,然后利用該權(quán)值進(jìn)行BP網(wǎng)絡(luò)的訓(xùn)練和仿真
clear?all;
tic?%開(kāi)始計(jì)時(shí)
%首先進(jìn)行遺傳算法
[PTRS1S2S]=nninit;%初始化網(wǎng)絡(luò)
aa=ones(S1)*[-1?1];
popu=30;%種群規(guī)模
initPpp=initializega(popuaa‘gabpEval‘);%初始化種群
gen=80?%遺傳代數(shù)
%遺傳計(jì)算尋求最優(yōu)解x
[x?endPop?bPop?trace]=ga(aa‘gabpEval‘[]initPpp[1e-6?1?1]‘maxGenTerm‘gen‘normGeomSelect‘[0.09][‘a(chǎn)rithXover‘][2]‘nonUnifMutation‘[2?gen?3]);
figure(1);
subplot(211);
plot(trace(:1)1./trace(:3)‘r-‘);
hold?on;
plot(trace(:1)1./trace(:2)‘b-‘);
xlabel(‘Generation‘);
ylabel(‘Sum-Squared?Error‘);
subplot(212);
plot(trace(:1)trace(:3)‘r-‘);
hold?on;
plot(trace(:1)trace(:2)‘b-‘);
xlabel(‘Gener
評(píng)論
共有 條評(píng)論