



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、利用MATLAB中gatool快速实现训练神经网络的遗传算法程序Deng Da-PengGenetic Algorithm,as an famous intelligent algorithm based on evolutionary thoughts, has been widely used to weights training and parameters optimization of neural networks. Essentially, GA is a global stochastic searching algorithm, which approximating gl
2、obal minima through Selection、Crossover and Mutation operators. It is difficult for many researchers to utilize advanced programming languages to implement GA. Actually, MATLAB provide us a very good graphic user interface of GA, named gatool, in GADS toolbox.Below contents illustrate how to use thi
3、s GUI tool to implement combination of GA and NN. In this case, I construct a feed forward network, which topological structure is 5-3-1, transfer functions are tansig and purelin for hidden and output layer, respectively. The key step is write a function to calculate fitness of chromosomes in GA po
4、pulation. Below code is implement this fitness calculating function in this case.function netout = netcal(pm) iN=5; hN=3;oN=1; % add your training sets here P= ; T= ; % Pre-processing data sets Pn,minP,maxP,Tn,minT,maxT = premnmx(P,T); net=newff(minmax(Pn),hN,oN,'tansig','purelin');
5、x,y=size(pm); for j=1:hN x2iw(j,:)=pm(1,(j-1)*iN+1):j*iN); end for k=1:oN x2lw(k,:)=pm(1,(iN*hN+1):(iN*hN+hN); end x2b=pm(1,(iN+1)*hN+1):y); x2b1=x2b(1:hN).' x2b2=x2b(hN+1:hN+oN).' net.IW1,1=x2iw; net.LW2,1=x2lw; net.b1=x2b1; net.b2=x2b2; netout=mse(sim(net,Pn)-Tn); % this error function pro
6、vides fitness for chromosomeOK, save this function with a name, i.e., netcal.m. Then, let's start gatool in MATLAB command line. The GUI of gatool is below.click then launchparameters settingclick and see helpenter num of weightsenter fitness functionFill name of fitness calculating function in
7、fitness function textbox, but note that add '' before function name. Calculate numbers of weights of network, in this case is 22. Then, you need set parameters of GA in right. This step need you understand GA. If any question, you can see help.Complete all these steps, click start button and
8、 launch training. When training process is end ,you will see a best chromosome in lower corner of left. This final result is best weight array of NN trained by GA. Change it to weight matrix and transfer to network according to fitness function code, then simulation with working sets and observe net
9、work performance.You can generate a m files through "generate M-file" in "file" menu. In this case, the M-file code is showed below. You may add some code in the end of this function for convenience.OK, it is end. Thanks for your reading and hope for your reviews and comments.bes
10、t chromosomefunction X,FVAL,REASON,OUTPUT,POPULATION,SCORES = untitled% This is an auto generated M file to do optimization with the Genetic Algorithm and% Direct Search Toolbox. Use GAOPTIMSET for default GA options structure. %Fitness functionfitnessFunction = netcal;%Number of Variablesnvars = 22
11、;%Start with default optionsoptions = gaoptimset;%Modify some parametersoptions = gaoptimset(options,'PopInitRange' ,-0.5 ; 0.5 );options = gaoptimset(options,'StallGenLimit' ,100);options = gaoptimset(options,'CrossoverFcn' , crossoverheuristic 1.2 );options = gaoptimset(options,'MutationFcn' , mutationgaussian 1 1 );options = gaoptimset(options,'Display' ,'of
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国3D打印软件项目创业计划书
- 乐理三级考试题及答案
- 生产安全事故应急处置预案管理实施计划方案
- 供应链金融仓单质押担保合同模板
- 财务会计人员保密与竞业限制合同
- 跨界合作代驾泊车服务合同范例
- 茶山茶园观光旅游项目租赁合同
- 2025沈阳市住宅用房屋租赁合同范本
- 2025化工原料类购销合同
- 2025汽车贷款抵押的合同
- 高考补充篇目:《菩萨蛮 书江西造口壁》课件+
- 2023年4月自考00534外国文学作品选试题及答案含评分标准
- 小学数学五年级下册第三单元《分数乘法》作业设计
- 走近核科学技术智慧树知到期末考试答案2024年
- 血气分析在妇产科的应用
- 人行现金业务培训课件
- 2024年广东广州市海珠区华洲街道雇员招聘笔试参考题库附带答案详解
- 金属表面处理的安全与环保要求
- 马拉之死艺术鉴赏
- 2024《HSK标准教程3》第3课 桌子上放着很多饮料 教案
- 中国传统元素之中国红
评论
0/150
提交评论