声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1300|回复: 0

[综合讨论] 请高手帮助解读遗传算法优化神经网络程序

[复制链接]
发表于 2006-8-5 17:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
% 用GA训练BP网络的权值、阈值
tic, % 开始计时
[P,T,R,S1,S2,S]=nninit; % BP网络初始化
aa=ones(S,1)*[-1 1];
popu=60; % 初始种群个数
initPpp=initializega(popu,aa,'gabpEval');
gen=700; % 遗传代数
[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网络所对应的权值、阈值
[W1 B1 W2 B2]=gadecod(x);
% 仿真结果
TT=simuff(P,W1,B1,'tansig',W2,B2,'purelin')
toc % 结束计时

其中,[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');这几句怎么理解,请高手指点.

[ 本帖最后由 cdwxg 于 2006-8-5 19:27 编辑 ]
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-18 01:20 , Processed in 0.073257 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表