数学建模社区-数学中国

标题: BP神经网络问题 [打印本页]

作者: jthawking    时间: 2009-8-31 16:58
标题: BP神经网络问题
以下是一段BP神经网络的代码,为什么运行时总是出现Index exceeds matrix dimensions的错误提示,麻烦哪位大侠帮忙下...1 J, b6 R9 W6 ?% Q' t+ {/ N7 Y, a
+ ]# Z% Q! I" j; |& F& E# a+ X
P=[27000 297.35  327.53  2658 6.31  68.3 15948 737  16316 583.89 1.96;# c$ L; c1 W% o8 R. Q1 X; f9 J
30619 325.00  390.51  2763 6.94  69.6 17130 789  18600 707.67 2.28;
9 ]. y! F9 E8 @33282 423.00  474.63  2801 5.73  69.7 17866 894  19886 861.88 2.32;. ?" P+ M' ]  j7 j4 B) G, H" j
33689 467.57  569.55  2887 7.76  69.8 18961 1015 20249 941.99 2.38;; F2 S" {& P, x0 M1 b! q; a( q. e
41020 538.17  616.25  2920 8.23  69.7 19688 1198 21626 1082.6 2.73;
8 L9 a3 E- u' c2 L, G4 f, z+ D" B43344 832.04  686.37  3495 8.87  68.3 24465 1361 23544 1373.4 2.89;1 z) [, r' }3 m6 s
46030 941.94  788.15  3495 9.57  68.2 24814 1710 24941 1756.5 2.82;0 A6 p9 Z6 P- c7 Y2 v) c, u
53887 1095.13 969.1   4885 9.65  68.7 36149 2100 25936 2199.5 3.08;
9 w& e1 {* T5 P9 B2 \. a$ L59271 1250.64 1092.6  5376 10.11 69.2 43008 2314 26596 2625.4 3.56;+ d  a. ^% S8 |
64507 1437.67 1176.1  6091 15.05 69.2 51946 2500 28494 3229.4 3.98;* n1 F+ Y: q- x# F9 y# @
70597 1671.29 1273.7  7305 16.81 69.2 65745 2614 29628 3744.7 4.98;) l1 H- c, ]; Y# Y) x& ]$ t' d8 R# P
79221 1905.03 1345    8023 18.6  69.1 70346 2798 30063 3792.6 5.1;
+ e/ Y9 {* S$ Y/ F% F+ [& q1 O/ v78812 2207.88 927.16  8328 20.52 69.3 71088 2964 30904 3951.64 5.21];
) ]+ [; {2 c4 M+ ?5 ~2 Y; jT=[3.1,3.6,4.2,4.8,6.7,9.1,13,18.9,29,51.1,78.2,103.5,128];. U/ W5 y" ]) D9 ?1 U6 r" D
[pn,minp,maxp]=premnmx(P);
8 N0 u1 A. d$ o0 X[tn,mint,maxt]=premnmx(T);
1 g" Q2 C3 i5 W7 c# C# i% inet=newff(minmax(pn(:,1:12)),[5,1],{'tansig','purelin'},'trainlm');
. k( }+ x0 o5 fnet=init(net);4 z- _/ ~% }5 W' M) I7 a
net.trainParam.epochs=20000;( t" G% c+ f0 v9 L  w/ c
net.trainParam.goal=0.0001;
8 v3 C7 l. z( C! P+ S% mnet.trainParam.lr=0.05;
/ c; ~6 X- D* E5 U  Inet=train(net,pn(:,1:12),tn(1:12));& d* v2 E2 }7 A
t_sim=sim(net,pn);
0 K8 `( [  `, m4 b* D3 [t_sim=postmnmx(t_sim,mint,maxt)
) f& {- a: Y" w5 Erelative_error=abs(t_sim(1:13)-T)./T& W% E$ e% [3 ]4 g" |' j
figure(1)3 x  O% M, l+ c  g
i=1:1:length(t_sim);
9 _3 J2 T' m8 {: S$ {9 ^8 lj=1:length(T);$ _) l5 a) v3 ?
plot(i,t_sim,'r',j,T,'bo')& ]0 D/ |$ |# v
legend('test value','true value','relative_error')
8 q. h3 V* z( L+ c, b2 p$ Gtitle('result compare between test value and true value')
作者: Kind    时间: 2009-8-31 17:48
不懂!!!!!!!!!!1111
作者: mmxyhlh    时间: 2009-8-31 17:59
yun.......
作者: LEIHENG    时间: 2009-8-31 18:47
不懂呀!!!!!!
作者: sunmin08    时间: 2009-8-31 18:57
好多数据呀!!
作者: lyyy    时间: 2009-8-31 19:40
这个是因为数组维数出问题了,你再看看吧。
作者: 诸葛孔明    时间: 2009-8-31 22:36
报错应该是说矩阵维数不对,net=newff(minmax(pn(:,1:12)),[5,1],{'tansig','purelin'},'trainlm');
  p( D5 J) V: k6 b. P2 C12应该改为11,后面的也要改。我试了一下,没有迭代完,还有错误········
作者: jthawking    时间: 2009-9-1 10:27
改过了了,但是程序运行到后来怎么还是有该错误提示呢,麻烦高手赐教... 7# 诸葛孔明
作者: wen1055    时间: 2009-9-1 10:34
把具体的问题发上来,更好理解!
作者: jthawking    时间: 2009-9-1 11:29
具体的问题就是Index exceeds matrix dimensions.现在前后维度都改过了阿。。。 9# wen1055
作者: cool_gr    时间: 2009-9-1 15:27
拿回去研究一下   呵呵
作者: cool_gr    时间: 2009-9-1 15:28
估计还是维度上的问题
作者: jthawking    时间: 2009-9-1 15:42
呵呵,可以了,谢谢。不过怎样进行下一年的预测呢?没有下一年的数据。。。。 12# cool_gr
作者: 文素    时间: 2011-1-14 22:43
?????????




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5