声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1647|回复: 13

[工具箱] [求助]神经网络训练错误

[复制链接]
发表于 2006-6-4 11:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我输入一段代码怎么会显示
??? P_train=[P(:,1)P(:,2)P(:,3)P(:,4)P(:,5)P(:,6)P(:,7)];
|
Error: Missing MATLAB operator.


代码如下:
p=[58478 135185 5.46 0.23 16.5 0.21 1005.3 585.44;
67884 152369 5.46 0.27 18.7 0.26 1105.6 575.03;
74462 182563 6.01 0.25 21.6 0.28 1204.6 601.23;
78345 201587 6.12 0.26 25.8 0.29 1316.5 627.89;
82067 225689 6.21 0.26 30.5 0.31 1423.5 676.95;
89403 240568 6.37 0.28 34.9 0.33 1536.2 716.32;
95933 263856 6.38 0.28 39.8 0.36 1632.6 765.24;
104790 285697 6.65 0.30 42.5 0.39 1753.2 812.22;
116694 308765 6.65 0.30 46.7 0.41 1865.5 875.26]';
t=[102569 52365 46251;
124587 60821 56245;
148792 69253 67362;
162568 79856 78165;
186592 91658 90548;
205862 99635 98758;
226598 109862 102564;
245636 120566 111257;
263595 130378 120356]';
a=[1 2 3 5 7 8];
P=p;
for i=1:6
P(a(i),:)=(p(a(i),:)-min(p(a(i),:)))/(max(p(a(i),:))-min(p(a(i),:)));
end
for i=1:3
T(i,:)=(t(i,:)-min(t(i,:)))/(max(t(i,:))-min(t(i,:)));
end
P_train=[P(:,1)P(:,2)P(:,3)P(:,4)P(:,5)P(:,6)P(:,7)];
T_train=[T(:,1)T(:,2)T(:,3)T(:,4)T(:,5)T(:,6)T(:,7)];
P_test=[P(:,8)P(:,9)];
T_test=[T(:,8)T(:,9)];
for i=1:5
net=newgrnn(P_train,T_train,i/10);
temp=sim(net,P_train);
j=3*i;
y_out(j-2,:)=temp(1,:);
y_out(j-1,:)=temp(2,:);
y_out(j,:)=temp(3,:);
temp=sim(net,P_test);
y(j-2,:)=temp(1,:);
y(j-1,:)=temp(2,:);
y(j,:)=temp(3,:);
end
y1=[y_out(1,:);y_out(2,:);y_out(3,:)];
y2=[y_out(4,:);y_out(5,:);y_out(6,:)];
y3=[y_out(7,:);y_out(8,:);y_out(9,:)];
y4=[y_out(10,:);y_out(11,:);y_out(12,:)];
y5=[y_out(13,:);y_out(14,:);y_out(15,:)];
y6=[y(1,:);y(2,:);y(3,:)];
y7=[y(4,:);y(5,:);y(6,:)];
y8=[y(7,:);y(8,:);y(9,:)];
y9=[y(10,:);y(11,:);y(12,:)];
y10=[y(13,:);y(14,:);y(15,:)];
for i=1:7
error1(i)=norm(y1(:,i)-T_train(:,i));
error2(i)=norm(y2(:,i)-T_train(:,i));
error3(i)=norm(y3(:,i)-T_train(:,i));
error4(i)=norm(y4(:,i)-T_train(:,i));
error5(i)=norm(y5(:,i)-T_train(:,i));
end
for i=1:2
error6(i)=norm(y6(:,i)-T_test(:,i));
error7(i)=norm(y7(:,i)-T_test(:,i));
error8(i)=norm(y8(:,i)-T_test(:,i));
error9(i)=norm(y9(:,i)-T_test(:,i));
error10(i)=norm(y10(:,i)-T_test(:,i));
end
plot(1:7,error1,'-*');
hold on;
plot(1:7,error1,'-+');
hold on;
plot(1:7,error1,'-h');
hold on;
plot(1:7,error1,'-d');
hold on;
plot(1:7,error1,'-o');
hold off;
figure;
plot(1:2,error1,'-*');
hold on;
plot(1:2,error1,'-+');
hold on;
plot(1:2,error1,'-h');
hold on;
plot(1:2,error1,'-d');
hold on;
plot(1:2,error1,'-o');
hold off;
回复
分享到:

使用道具 举报

发表于 2006-6-4 11:35 | 显示全部楼层
P_train=[P(:,1),P(:,2),P(:,3),P(:,4),P(:,5),P(:,6),P(:,7)];
T_train=[T(:,1),T(:,2),T(:,3),T(:,4),T(:,5),T(:,6),T(:,7)];
P_test=[P(:,8),P(:,9)];
T_test=[T(:,8),T(:,9)];
其他地方我没看
反正这个地方错了,你错的问题是这个地方
其他的类似的你改下就好了
发表于 2006-6-4 11:37 | 显示全部楼层
你这个问题去新手上路专区哈...http://forum.vibunion.com/forum-66-1.html
里面有个帖子http://forum.vibunion.com/thread-4677-1-1.html关于威望的
还有,不要在别人的帖子下面回复此类问题嘛
你可以随便问,发个帖子问,我们还可以把你的帖子转过去...呵呵
去看看吧
发表于 2006-6-4 11:48 | 显示全部楼层
辛苦cdwxg斑竹了~~
 楼主| 发表于 2006-6-4 11:50 | 显示全部楼层
谢谢  我按照你改的后运行程序又出现了新的问题
??? Error using ==> plot
Vectors must be the same lengths.
发表于 2006-6-4 11:51 | 显示全部楼层
  1. figure;
  2. plot(1:2,error1,'-*');
  3. hold on;
  4. plot(1:2,error1,'-+');
  5. hold on;
  6. plot(1:2,error1,'-h');
  7. hold on;
  8. plot(1:2,error1,'-d');
  9. hold on;
  10. plot(1:2,error1,'-o');
  11. hold off;
复制代码

这个部分有错哈
因为你这个部分是1:2对应的是6,7,8..
发表于 2006-6-4 11:52 | 显示全部楼层
日....你娃这两天没见你呢...呵呵
想我不?
发表于 2006-6-4 11:56 | 显示全部楼层
figure;
plot(1:2,error1,'-*');
hold on;
plot(1:2,error1,'-+');
hold on;
plot(1:2,error1,'-h');
hold on;
plot(1:2,error1,'-d');
hold on;
plot(1:2,error1,'-o');
hold off;
这个部分有错哈
因为你这个部分是1:2对应的是6,7,8.. for i=1:7
error1(i)=norm(y1(:,i)-T_train(:,i));
error2(i)=norm(y2(:,i)-T_train(:,i));
error3(i)=norm(y3(:,i)-T_train(:,i));
error4(i)=norm(y4(:,i)-T_train(:,i));
error5(i)=norm(y5(:,i)-T_train(:,i));
end
for i=1:2
error6(i)=norm(y6(:,i)-T_test(:,i));
error7(i)=norm(y7(:,i)-T_test(:,i));
error8(i)=norm(y8(:,i)-T_test(:,i));
error9(i)=norm(y9(:,i)-T_test(:,i));
error10(i)=norm(y10(:,i)-T_test(:,i));
1:7对应的是error1到5
1:2对应的是error6-7
所以你下面才有length不对
因为你plot时候1:2也用的error1

plot(1:7,error1,'-*');
hold on;
plot(1:7,error1,'-+');
hold on;
plot(1:7,error1,'-h');
hold on;
plot(1:7,error1,'-d');
hold on;
plot(1:7,error1,'-o');
hold off;
figure;
plot(1:2,error1,'-*');
hold on;
plot(1:2,error1,'-+');
hold on;
plot(1:2,error1,'-h');
hold on;
plot(1:2,error1,'-d');
hold on;
plot(1:2,error1,'-o');
hold off;
另外我感觉你是不是错了
是不是后面的error应该1-9都有,你怎么全部是error1 啊
 楼主| 发表于 2006-6-4 12:03 | 显示全部楼层
啊啊啊啊   知道了  谢谢
 楼主| 发表于 2006-6-4 12:07 | 显示全部楼层
呵呵  老大  我如果还要根据以上的数据做个bp的预测 要注意些什么呢 比如说输入神经元个数,中间层神经元个数确定,选择中间层神经元个数等
发表于 2006-6-4 13:18 | 显示全部楼层
这个就不晓得了
BP与神经网络是最近在学的
你能否自己查下相关材料呢?这个属于理论范畴吧
呵呵,如果是程序问题,还可以,理论我需要以后学好了才行:)
你先自己找点资料看,再有问题再说,好?
发表于 2006-6-4 18:41 | 显示全部楼层
输入层神经元是根据你的训练样本来的(取最简洁但包含最多信息量的影响因素),隐含层神经元数确定还没有具体的公式,不过一帮都是用经验试凑法的,最先用2N+1,N为输入层神经元个数,然后适当的增加或减少隐含层神经元个数,比较不同结构的预测精度,最后再确定最加的网络结构

[此贴子已经被作者于2006-6-4 18:48:31编辑过]

发表于 2006-6-4 18:43 | 显示全部楼层
你这个问题去新手上路专区哈...http://forum.vibunion.com/forum-66-1.html
里面有个帖子http://forum.vibunion.com/thread-4677-1-1.html关于威望的
还有,不要在别人的帖子下面回复此类问题嘛
你可以随便问,发个帖子问,我们还可以把你的帖子转过去...呵呵
去看看吧

呵呵,不好意思,这个问题我曾经也问过的。刚来的时候是很陌生的,不要怪人家。^_^
发表于 2006-6-6 08:29 | 显示全部楼层
t2145011、ericlin加威望1点,cdwxg加威望2点。

多情清秋
06.6.6
[此贴子已经被作者于2006-6-6 8:30:17编辑过]

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-9 09:39 , Processed in 0.076413 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表