我创建了一个神经网络 matlab。这是脚本:
加载数据.mat;
输入=数据(:,1:8)';
目标=数据(:,9)';
隐藏层大小 = 10;
净=模式网(隐藏层大小);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax', 'mapstd','processpca'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax','mapstd','processpca'};
净=结构(净);
net.inputs{1}.processParams{2}.ymin = 0;
net.inputs{1}.processParams{4}.maxfrac = 0.02;
net.outputs{2}.processParams{4}.maxfrac = 0.02;
net.outputs{2}.processParams{2}.ymin = 0;
净=网络(净);
net.divideFcn = 'divideind';
net.divideMode = '样本'; % 划分每个样本
net.divideParam.trainInd = 1:428;
net.divideParam.valInd = 429:520;
net.divideParam.testInd = 521:612;
net.trainFcn = 'trainscg'; % 缩放共轭梯度反向传播
net.performFcn = 'mse'; % 均方误差
net.plotFcns = {'plotperform','plottrainstate','ploterrhist','plotregression','plotconfusion','plotroc'};
净=初始化(净);
net.trainParam.max_fail=20;
[net,tr] = train(net,inputs,targets);
输出=净(输入);
错误= gsubtract(目标,输出);
性能=执行(净,目标,输出)
现在我想保存网络的权重和偏差并写出方程。我保存了权重和偏差:
W1=net.IW{1,1};
W2=net.LW{2,1};
b1=net.b{1,1};
b2=net.b{2,1};
所以,我已经完成了数据预处理,我写了下面的等式
最大范围=0;
[y,ps]=removeconstantrows(输入, max_range);
ymin=0;
ymax=1;
[y,ps2]=mapminmax(y,ymin,ymax);
ymean=0;
ystd=1;
y=mapstd(x,ymean,ystd);
最大压裂=0.02;
y=processpca(y,maxfrac);
在=y';
uscita=tansig(W2*(tansig(W1*in+b1))+b2);
但是使用相同的输入 input=[1:8] 我得到不同的结果。为什么?怎么了?请帮帮我!这一点很重要!
我使用 Matlab R2010B