jilly120 发表于 2005-12-8 10:54

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

<P>哪位大虾可以帮小女子看看下面的程序呀?</P>
<P>p=</P>
<P>t=; </P>
<P>pp=; </P>
<P>tt = ; </P>
<P>LearnRate = 0.01;<BR>LearnGoal = 0.01;<BR>LearnEpoch = 4000;<BR>HiddenLayer = 3;<BR>OutputLayer = 1;</P>
<P> = fuc_training(p,t,pp,tt,LearnRate,LearnGoal,LearnEpoch,HiddenLayer,OutputLayer);</P>
<P>a=0;<BR>=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 =fuc(p,t,pp,tt,speed,goal,epoch,hiden_layer,output_layer)</P>
<P>%preprocessing the input vectors<BR> = prestd(p);<BR> = prepca(p,0.02);<BR>=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,,{'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> = 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>% = 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('\nthe 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=;</P>
<P>t=; </P>
<P>pp=; </P>
<P>tt = ; </P>

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

suffer 发表于 2005-12-8 20:57

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

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

[ 本帖最后由 ChaChing 于 2009-7-11 23:27 编辑 ]

jilly120 发表于 2005-12-8 21:39

多谢suffer的提醒!<BR>pic的代码如下:<BR>function a=fun(a,b,R)<BR>hold off;<BR>=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>

suffer 发表于 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>

jilly120 发表于 2005-12-10 15:41

呵呵,这正是我想问的问题!<BR>我把程序开始的P矩阵换成了:<BR>
<P>p=;</P>
<P>t=; </P>
<P>pp=; </P>
<P>tt = ; <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 measuredvalue is 6.9 6.2 6.2 4.3 4.9 5.2<BR><BR>误差很大,而且只运行了一代!</P>

happy 发表于 2005-12-10 18:40

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

t明显和上面的不对应阿
页: [1]
查看完整版本: 哪位看到的大虾帮帮忙啊?谢谢!