matlab网上求助,求助MATLAB BP神经网络

clear all

close all

at=[{'日期:2001至2010'};{'交通量'};{'GDP'};{'人均可支配收入'};{'人口总量'};{'汽车保有量'};......

{'旅游人均居民消费水平'};{'工业生产总值'};{'农业生产总值'}];

ys='brgmcyk';  %未知？

%%输入数据及目标数据

pd=aa(:,1:10)';

[pn,minp,maxp]=premnmx(pd);

p=pn(1:9,:)';  %p存放训练的输入数据

t=pn(10,:)';   %t存放训练的目标数据

%%%测试数据及目标数据

pdc=aa(:,5:10)'; %pdc表示测试数据

[pnc,minpc,maxpc]=premnmx(pdc); %

ptest=pnc(1:5,:)';%%ptest存放测试集的输入数据

ttest=pnc(6,:)';%%ttest存放测试集的目标数据

%计算训练集的样本个数和输入元素个数

%Q存放样本个数

%R存放输入元素个数

[Q,R]=size(p);

%隐含层神经元个数

H=10;                                            %%隐层神经元数(？？)

%创建一个新的前向神经网络

net=newff(minmax(p'),[H,1],{'tansig','purelin'},'trainlm');

% 初始化输入层权值和偏置值

net.IW{1,1}=0.1*rand(H,R);

inputWeights=net.IW{1,1};

net.b{1}=0.1*rand(H,1);

inputbias=net.b{1};

% 初始化网络层权值和偏置值

net.LW{2,1}=0.1*rand(1,H);

layerWeights=net.LW{2,1};

net.b{2}=0.1*rand(1);

layerbias=net.b{2};

%设置网络训练参数

%设置显示间隔

net.trainParam.show=50;

%设置学习速率

net.trainParam.lr=0.05;

%设置动量项

net.trainParam.mc=0.25

%设置训练次数

net.trainParam.epochs=5000;

%设置训练目标值

net.trainParam.goal=1e-5;

%训练BP网络

P=p';

T=t';

[net,tr]=train(net,P,T);

%仿真计算测试集的输出

output=sim(net,ptest');

%将计算结果输出到Excel文件output_ann.xls中

%绘制仿真结果图

figure(1);

plot(output,'ok');

%保持图形不被后续图形绘制操作刷新

hold on;

%绘制阈值上下限

x=linspace(1,6);

y1=0.51;

y2=0.65;

plot(x,y1,'-k',x,y2,'-k');

net =

Neural Network object:

architecture:

numInputs: 1

numLayers: 2

biasConnect: [1; 1]

inputConnect: [1; 0]

layerConnect: [0 0; 1 0]

outputConnect: [0 1]

targetConnect: [0 1]

subobject structures:

inputs: {1x1 cell} of inputs

layers: {2x1 cell} of layers

outputs: {1x2 cell} containing 1 output

targets: {1x2 cell} containing 1 target

biases: {2x1 cell} containing 2 biases

inputWeights: {2x1 cell} containing 1 input weight

layerWeights: {2x2 cell} containing 1 layer weight

functions:

initFcn: 'initlay'

performFcn: 'mse'

trainFcn: 'trainlm'

parameters:

initParam: (none)

performParam: (none)

trainParam: .epochs, .goal, .max_fail, .mem_reduc,

.min_grad, .mu, .mu_dec, .mu_inc,

.mu_max, .show, .time, .lr,

.mc

weight and bias values:

IW: {2x1 cell} containing 1 input weight matrix

LW: {2x2 cell} containing 1 layer weight matrix

b: {2x1 cell} containing 2 bias vectors

other:

userdata: (user stuff)

TRAINLM, Epoch 0/5000, MSE 0.342733/1e-005, Gradient 1.01865/1e-010

TRAINLM, Epoch 5/5000, MSE 4.729e-010/1e-005, Gradient 0.000224833/1e-010

TRAINLM, Performance goal met.

??? Error using ==> network.sim

Inputs are incorrectly sized for network.

Matrix must have 9 rows.

Error in ==> xmyy at 56

output=sim(net,ptest');

06-16

05-04
01-27 17万+
09-10
06-20
03-25

“相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

©️2022 CSDN 皮肤主题：深蓝海洋 设计师：CSDN官方博客

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