声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1597|回复: 5

哪位看到的大虾帮帮忙啊?谢谢!

[复制链接]
发表于 2005-12-8 10:54 | 显示全部楼层 |阅读模式

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

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

x
<P>哪位大虾可以帮小女子看看下面的程序呀?</P>
<P>p=[307 287 258 151 274 364 430 331 291 188 250 254 239 426 315 370 376 273 256 344 260 252 389 312 181 314 313 228 620 490 466 254 311;<BR>   246 248 230 154 236 338 274 221 230 166 234 241 233 296 263 295 211 244 214 302 230 245 378 248 152 294 280 198 362 321 260 196 280;<BR>0.2874  0.2006  0.2696  0.3213  0.2631  0.2026  0.2734  0.2480  0.2164  0.3512  0.2981  0.2828  0.3438  0.2023  0.1906  0.2025  0.2134  0.2164  0.2422  0.2027  0.2828  0.2828  0.1859  0.2133  0.3061  0.1887  0.1909  0.2529  0.1548  0.2243  0.2760  0.2941  0.2343; <BR>0.2874  0.2006  0.2696  0.3213  0.2631  0.1887  0.2734  0.2480  0.2164  0.3512  0.2981  0.2828  0.3438  0.1787  0.1906  0.1811  0.2134  0.2164  0.2340  0.1887  0.2828  0.2828  0.1764  0.2133  0.3061  0.1723  0.1791  0.2529  0.1548  0.1958  0.2760  0.2941  0.2343; <BR>0.902  0.495  0.763  0.737  0.870  0.553  1.060  0.747  0.587  0.938  0.830  0.743  0.747  0.535  0.583  0.350  0.648  0.445  0.580  0.552  0.823  0.738  0.535  0.498  0.965  0.318  0.358  0.440  0.535  0.732  1.127  1.097  0.653 ;<BR>2.8 1 2 1 2 2 2.6 1.667 1.333 2 2.25 2 1 1.667 1.5 1.33 1.94 1 1 1.67 2 2 1 2.08 1 1 1 1 2.8 2.8 3.12 1.67 2.6;<BR>296 142 235 212 237 178 341 223 150 290 284 262 249 180 161 165 186 162 184 173 259 262 163 167 233 138 134 180 195 261 403 276 212;<BR>96.55  78.69  88.44  73.98  89.43  90.50  104.40  91.91  81.41  85.83  92.30  91.03  96.46  93.49  80.08  88.31  89.14  80.69  81.03  86.99  90.75  91.18  90.78  84.25  76.15 79.90  79.93  78.87  98.23  103.68  108.08  89.29  90.67;<BR>145.51  157.70  119.67  132.71  117.00  157.56  124.62  142.96  132.63  147.07  132.88  151.11  117.99  134.21  167.91  221.02  480.86  163.25  107.85  156.04  158.11  158.11  209.12  147.36  8.35  162.15  170.85  171.20  260.63  149.37  165.50  82.82  125.50; <BR>145.51  157.70  119.70  132.70  117.00  406.80  124.60  143.00  132.60  147.10  132.90  151.10  118.00  385.95  167.90  419.04  480.90  163.20  104.17  417.64  158.10  158.10  445.42  147.36  8.35  423.66  423.51  171.20  260.63  388.33  165.50  395.20  90.67]</P>
<P>t=[134.8  296.5  96.5  412.6  118.4  219.0  44.2  189.1  378.0  169.8  81.2  210.2  141.9  213.3  206.0  85.2  318.8  259.4  201.6  202.8  150.3  154.3  254.0  408.9  259.6 439.4  445.0  287.8  75.8  94.6  92.7  189.9  221.0]; </P>
<P>pp=[318 294   299 401  358;<BR>284  276  303  332  263;<BR>0.2197  0.2385  0.2340  0.1907  0.2264;<BR>0.2197  0.2385  0.2026  0.1907  0.2264;<BR>0.616 0.696 0.501 0.46 0.696; <BR>2 2.57 1.67 1.67 2.25;<BR>192  214  201  169  214;<BR>88.66  89.79  88.41  91.36  92.33 ;<BR>204.31  215.52  230.95  250.39  237.44; <BR>204.31  215.52  410.00  250.39  237.44]; </P>
<P>tt = [247.4 283.4 199.2 99.3 286.4]; </P>
<P>LearnRate = 0.01;<BR>LearnGoal = 0.01;<BR>LearnEpoch = 4000;<BR>HiddenLayer = 3;<BR>OutputLayer = 1;</P>
<P>[pred,cv,net,TR,R2] = fuc_training(p,t,pp,tt,LearnRate,LearnGoal,LearnEpoch,HiddenLayer,OutputLayer);</P>
<P>a=0;<BR>[Save_or_not]=SaveDlg(a);<BR>switch Save_or_not<BR>case 'Yes',<BR>        save qq p t net TR R2 pred pp tt;%DemoResult is the filename to be saved<BR>    otherwise<BR>end</P>
<P>function [pred,cv,net,TR,R2]=fuc(p,t,pp,tt,speed,goal,epoch,hiden_layer,output_layer)</P>
<P>%preprocessing the input vectors<BR>[p,meanp,stdp] = prestd(p);<BR>[p,transMat] = prepca(p,0.02);<BR>[p,minp,maxp,t,mint,maxt]=premnmx(p,t);<BR>pp = trastd(pp,meanp,stdp);   <BR>pp = trapca(pp,transMat);<BR>pp =tramnmx(pp,minp,maxp);<BR>Pt = minmax(p);<BR>net=newff(Pt,[hiden_layer output_layer],{'tansig','purelin'},'trainlm');<BR>fprintf('\n\n');<BR>echo off ;<BR>net.trainParam.lr=speed;<BR>net.trainParam.epochs=epoch;<BR>net.trainParam.goal=goal;<BR>net.trainParam.min_grad=1e-15;<BR>net.trainParam.show=500;<BR>%net.trainParam.max_fail=100;<BR>%net.trainParam.mem_reduc=10;<BR>[net,TR] = train(net,p,t);<BR>pred = sim(net,pp);<BR>pred = postmnmx(pred,mint,maxt);<BR>cv = (pred-tt)./tt;<BR>R = corrcoef(pred,tt);<BR>%R2 = R(1,2);<BR>%[row,vol] = size(tt);</P>
<P>fprintf('\nthe predicted value is ');<BR>fprintf('%12.4f',pred);<BR>fprintf('\nthe measured value is  ');<BR>fprintf('%12.4f',tt);<BR>fprintf('\n  the error is         ');<BR>fprintf('%12.4f',cv);<BR>%fprintf('\nthe correlate coefficient is %6.4f', R2);</P>
<P><BR>pic(tt,pred,R);</P>
<P><BR>function =Save_Dlg(a)<BR>s=questdlg('是否保存训练结果?','保存训练结果','Yes','No','No');</P>

<P>我想把里面的P矩阵换成下面的数据:</P>
<P>p=[2616 810.33 485.33 4450.33;<BR>   1.3748 1.3205 1.239 1.1276;<BR>  45 85 18 22; <BR>  0.3 0.39 0.46 0.72];</P>
<P>t=[4.9 5.9 4.0 6.5;<BR>   4.5 5.3 3.6 6.1;<BR>   4.6 5.5 3.6 6.0;<BR>   2.3 2.2 2.7 3.6;<BR>   2.4 2.0 3.7 5.1;<BR>   2.4 2.8 3.9 5.4]; </P>
<P>pp=[1974.67;<BR>1.1948;<BR>15;<BR>0.62]; </P>
<P>tt = [6.9;<BR>    6.2;<BR>    6.2;<BR>    4.3;<BR>    4.9;<BR>    5.2]; </P>

<P>明明已经换了,可为什么出来的结果还是预测的原来的数据的值呢???是不是要建立一个叫做“MATLAB data file"的文件呢?这个文件在哪里创建呢?</P>
<P>还有一个问题就是我只有四个样本,是不是对于神经网络预测来说太少了呢?</P>
<P>哪位高手明白,请帮帮忙吧!谢谢呀!!</P>
<P>或者直接回复到我的邮箱<a href="mailtjjpurple120@tom.com" target="_blank" >jjpurple120@tom.com</A>也可以,谢谢!!</P>
回复
分享到:

使用道具 举报

发表于 2005-12-8 20:57 | 显示全部楼层

回复:(jilly120)哪位看到的大虾帮帮忙啊?谢谢!

明明已经换了,可为什么出来的结果还是预测的原来的数据的值呢???
这句话不是很明白,能否说清出点
4组样本确实很少
另外你给的程序中少了pic这段代码,运行不了

[ 本帖最后由 ChaChing 于 2009-7-11 23:27 编辑 ]
 楼主| 发表于 2005-12-8 21:39 | 显示全部楼层
多谢suffer的提醒!<BR>pic的代码如下:<BR>function a=fun(a,b,R)<BR>hold off;<BR>[row,col]=size(a);<BR>for i=1:col<BR>   plot(a(i),b(i),':ro');<BR>   hold on;<BR>end<BR><BR>temp1=min(a);<BR>temp2=min(b);<BR>x=zeros(1,2);<BR>x(1)=min(temp1,temp2);<BR>temp1=max(a);<BR>temp2=max(b);<BR>x(2)=max(temp1,temp2);<BR>y=x;<BR>plot(x,y);<BR>hold off;<BR>title('The Prediction');<BR>xlabel('Meas Data');<BR>ylabel('Pred Data');<BR>hold off;<BR><BR><BR>可否帮我看看整个程序是否有问题呢?因为我运行时只训练1epoch,怎么就停止了呢?<BR>
发表于 2005-12-9 15:46 | 显示全部楼层

回复:(jilly120)哪位看到的大虾帮帮忙啊?谢谢!

<P>我运行上述程序的结果<BR>TRAINLM, Epoch 0/4000, MSE 0.304479/0.01, Gradient 11.2279/1e-015<BR>TRAINLM, Epoch 500/4000, MSE 0.018452/0.01, Gradient 0.00154877/1e-015<BR>TRAINLM, Epoch 1000/4000, MSE 0.0184515/0.01, Gradient 6.7753e-005/1e-015<BR>TRAINLM, Epoch 1500/4000, MSE 0.0184514/0.01, Gradient 0.000540231/1e-015<BR>TRAINLM, Epoch 2000/4000, MSE 0.0184513/0.01, Gradient 4.81969e-005/1e-015<BR>TRAINLM, Epoch 2500/4000, MSE 0.0184513/0.01, Gradient 0.000500366/1e-015<BR>TRAINLM, Epoch 3000/4000, MSE 0.0184512/0.01, Gradient 6.42612e-005/1e-015<BR>TRAINLM, Epoch 3500/4000, MSE 0.0184512/0.01, Gradient 4.57205e-005/1e-015<BR>TRAINLM, Epoch 4000/4000, MSE 0.0184512/0.01, Gradient 4.13985e-005/1e-015<BR>TRAINLM, Maximum epoch reached, performance goal was not met.</P>
<P><BR>the predicted value is     143.0908     80.4107    121.4202    156.2426     75.6621<BR>the measured value is      247.4000    283.4000    199.2000     99.3000    286.4000<BR>  the error is              -0.4216     -0.7163     -0.3905      0.5734     -0.7358</P>
 楼主| 发表于 2005-12-10 15:41 | 显示全部楼层
呵呵,这正是我想问的问题!<BR>我把程序开始的P矩阵换成了:<BR>
<P>p=[2616 810.33 485.33 4450.33;<BR>   1.3748 1.3205 1.239 1.1276;<BR>  45 85 18 22; <BR>  0.3 0.39 0.46 0.72];</P>
<P>t=[4.9 5.9 4.0 6.5;<BR>   4.5 5.3 3.6 6.1;<BR>   4.6 5.5 3.6 6.0;<BR>   2.3 2.2 2.7 3.6;<BR>   2.4 2.0 3.7 5.1;<BR>   2.4 2.8 3.9 5.4]; </P>
<P>pp=[1974.67;<BR>1.1948;<BR>15;<BR>0.62]; </P>
<P>tt = [6.9;<BR>    6.2;<BR>    6.2;<BR>    4.3;<BR>    4.9;<BR>    5.2]; <BR><BR>在运行时只训练1epoch,就停止了<BR><BR>结果如下:<BR><BR>the predicted value is 4.7 4.5 3.5 4.2 5.2 3.7<BR>the measured  value is 6.9 6.2 6.2 4.3 4.9 5.2<BR><BR>误差很大,而且只运行了一代!</P>
发表于 2005-12-10 18:40 | 显示全部楼层

回复:(jilly120)哪位看到的大虾帮帮忙啊?谢谢!

t明显和上面的不对应阿
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-11-21 01:25 , Processed in 0.063519 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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