matlab经典实例,BP神经网络matlab实例(简单而经典)

p=p1';t=t1';

[pn,minp,maxp,tn,mint,maxt]=premnmx(p,t); %原始数据归一化

%premnmx Preprocesses data so that minimum is -1 and maximum is 1.

net=newff(minmax(pn),[5,1],{'tansig','purelin'},'traingdx');%设置网络,建立相应的BP网络

%minmax returns the Rx2 matrix PR of minimum and maximum values for each row of P. net.trainParam.show=2000; % 训练网络

net.trainParam.lr=0.01;

net.trainParam.epochs=100000;

net.trainParam.goal=1e-5;

[net,tr]=train(net ,pn,tn); %调用TRAINGDM算法训练BP网络pnew=pnew1';

pnewn=tramnmx(pnew,minp,maxp);

% tramnmx TRAMNMX transforms the network input set using

% minimum and maximum values that were previously

% computed by PREMNMX. This function needs to be

%used when a network has been trained using data normalized

%by PREMNMX. All subsequent inputs to the network need to

%be transformed using the same normalization.

anewn=sim(net,pnewn); %对BP网络进行仿真

anew=postmnmx(anewn,mint,maxt); %还原数据

y=anew';

% Postprocesses data which has been preprocessed by PREMNMX. POSTMNMX postprocesses %the network training

% set which was preprocessed by PREMNMX. It converts

% the data back into unnormalized units.

1、BP网络构建

(1)生成BP网络

=

net newff PR S S SNl TF TF TFNl BTF BLF PF

(,[1 2...],{ 1 2...},,,)

R?维矩阵。

PR:由R维的输入样本最小最大值构成的2

S S SNl:各层的神经元个数。

[1 2...]

TF TF TFNl:各层的神经元传递函数。

{ 1 2...}

BTF:训练用函数的名称。

(2)网络训练

net tr Y E Pf Af train net P T Pi Ai VV TV

=

[,,,,,] (,,,,,,)

(3)网络仿真

=

[,,,,] (,,,,)

Y Pf Af E perf sim net P Pi Ai T

{'tansig','purelin'},'trainrp'

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值