• 大小: 2KB
    文件类型: .m
    金币: 2
    下载: 1 次
    发布日期: 2021-05-22
  • 语言: Matlab
  • 标签:

资源简介

用matlab编BP神经网络预测程序,遗传算法优化BP 神经网络在数据预测方面的应用

资源截图

代码片段和文件信息

clear all
close all
p=textread(‘data.txt‘);
p1=p‘;
t=p1;
[pnminpmaxptnmintmaxt] = premnmx(p1t);
p_train=[pn(1:);pn(2:);pn(3:);pn(4:);pn(5:);pn(6:);pn(7:);pn(8:);pn(9:);pn(10:);pn(11:);pn(12:);pn(13:);...
    pn(14:);pn(15:);pn(16:);pn(17:);pn(18:);pn(19:);pn(20:);pn(21:);pn(22:);pn(23:);pn(24:);pn(25:);pn(26:);pn(27:);...
    pn(28:);pn(29:);pn(30:);pn(31:);pn(32:);pn(33:);pn(34:);pn(35:);pn(36:);pn(37:);pn(38:);pn(39:)]‘
t_train=[pn(2:);pn(3:);pn(4:);pn(5:);pn(6:);pn(7:);pn(8:);pn(9:);pn(10:);pn(11:);pn(12:);pn(13:);pn(14:);pn(15:);pn(16:);...
    pn(17:);pn(18:);pn(19:);pn(20:);pn(21:);pn(22:);pn(23:);pn(24:);pn(25:);pn(26:);pn(27:);pn(28:);pn(29:);pn(30:);...
    pn(31:);pn(32:);pn(33:);pn(34:);pn(35:);pn(36:);pn(37:);pn(38:);pn(39:);;pn(40:)]‘;
save p_train
save t_train
threshold=minmax(p_train); 
%创建网络
net=newff(threshold[122512]{‘tansig‘‘tansig‘‘purelin‘}‘trainlm‘);
%下面使用遗传算法对网络进行优化
P=p_train;
T=t_train;
R=size(P1);
S2=size(T1);
S1=25;%隐含层节点数
S=R*S1+S1*S2+S1+S2;%遗传算法编码长度
aa=ones(S1)*[-11];
popu=50;%种群规模
initPpp=initializega(pop

评论

共有 条评论