我的bp神经网络为什么得出同样的结果
clearclc
p=[3.3 4.08 4.98 2.43 3.01 3.68 1.9 2.37 2.91;...
4.63 5 5.78 3.25 3.53 4.12 2.42 2.65 3.12;...
5.65 8.46 11.4 4.24 6.35 8.55 3.39 5.08 6.85;...
7.52 10.59 14.67 5.64 7.95 11 4.52 6.36 8.81;...
6.12 8.87 12.17 4.41 6.46 8.94 3.37 5.02 7];
for i=1:5
p(i,:)=(p(i,:)-min(p(i,:)))/(max(p(i,:))-min(p(i,:)));
end
t=[3000 3000 3000 4000 4000 4000 5000 5000 5000;...
4.8 6.4 8 4.8 6.4 8 4.8 6.4 8];
u=t;
for i=1:2
t(i,:)=(t(i,:)-min(t(i,:)))/(max(t(i,:))-min(t(i,:)));
end
net=newff(minmax(p),,{'tansig' 'purelin'},'trainlm');
y1=sim(net,p);
%%%以下为训练网络
net.trainParam.show=10;
net.trainParam.lr=0.01;
net.trainParam.epochs=8000;
net.trainParam.goal=0.001;
net=train(net,p,t);
y2=sim(net,p)
%%%以下为预测
clc
p1=;
out=sim(net,p1)
for i=1:2
predict(i)=out(i)* (max(u(1,:))-min(u(1,:)))+ min(u(1,:));
end
predict
然后每次改p1中的值,得出的都是一样 当前运行的结果:
out =
-0.6060
2.8510
predict =
1.0e+003 *
1.7879 8.7019
p1=;=〉p1=;后输出的结果:
out =
-0.0501
3.0357
predict =
1.0e+003 *
2.8997 9.0713
不一样啊
页:
[1]