马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
小弟编辑一段bp神经网络程序,运行时,系统报错提示:Targets are incorrectly sized for network.Matrix must have 1 rows. 是否bp神经网络的目标输出都只能是一维向量?如果多维可以,此程序应如何修改?请大家多指教,期待尽快回复,急!!!
pp=[p1;p2;p3;p4;p5;p6;p7;p8;p9]; %pp为540*21矩阵
T=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0];
p=pp';
t=T;
% 归一化训练样本
for i=1:21
p(:,i)=(p(:,i)-min(p(:,i)))/(max(p(:,i))-min(p(:,i)));
end
%----------------------确定隐层神经元---------------------------------------------
net=newff(minmax(p),[11,1],{'tansig','logsig'},'traingdx'); %最速下降BP法,节省机器内存
inputWeights=net.iw{1,1};
inputbias=net.b{1,1};
layerWeights=net.iw{2,1};
layerbias=net.b{2,1};
net.trainParam.lr = 0.05;
net.trainParam.show = 50;
net.trainParam.epochs = 10000;
net.trainParam.goal = 0.0002;
net=train(net,p,t);
YY=sim(net,p); |