home96 发表于 2008-4-27 19:55

如何解决神经网络训练值为正但模拟值有负值的问题

请教个问题:训练的数集都是正值,但模拟出来的有些负值,不符合实际情况,请大家帮忙看看。

谢谢!附件里面是数据和程序。

下面是训练模拟时的主要程序,请帮忙看看有没问题。

   net=newff(minmax(P_train),,{'tansig','tansig','purelin'},'traingdx');
    net.trainparam.epochs=400;
    net.trainparam.goal=0.0001
    net.trainparam.show=50;
    net=train(net,P_train,T_train)
    T_moni=sim(net,P_test)

——————————————————————————————————————————————————
以下为附件内容:
现在有个问题:T_moni 的值有几个是负的,而 T_moni 代表的是生物量,不应该为负,请帮忙看下是怎么回事,是不是程序有问题,谢谢!
size(P_train)=
size(T_train)=   
size(P_test)=
size(T_test)=
下面是数据:P_train = [0.008662434 0.033743759 0.055811172 0.005937322 0.002575783 0.036466071 0.044155905 0.019700634 0.051327317 0.037565029 0.025642779 0.037749355 0.00843857 -5.85657E-06 0.108041267 0.102046618 0.253090739 0.069778002 0.110318322 0.157306449 0.227409147 0.117720152 0.20464526 0.132722686 0.063227596 0.156450342 0.056464958 0.057270238 0.232589872 0.194712289 0.368684447 0.108509033 0.220799348 0.25914446 0.40389676 0.338495969 0.399126218 0.304627662 0.217756414 0.406850839 0.079795361 0.073202986 0.397881617 0.313364362 0.650305412 0.272594278 0.303458271 0.408034985 0.565355186 0.500879897 0.60403673 0.532982001 0.48712883 0.500681325 0.245333203 0.169574184 0.537665842 0.567597311 0.406860468 0.422401784 0.465689872 0.363069036 0.552937441 0.380518257 0.657144928 0.621928925 0.544031326 0.603645472 0.373423045 0.378849107 0.453827638 0.522279704 0.434981532 0.53807692 0.316305067 0.288329639 0.436676005 0.446361775 0.532398779 0.528188062 0.501559261 0.511721399 0.385581821 0.449908114 ...
0.443434207 0.534924553 0.468376211 0.413218912 0.243518077 0.244016874 0.416792524 0.408573849 0.672960872 0.638075267 0.490768006 0.460205496 0.342284412 0.372193559 0.377480809 0.393577256 0.364548686 0.348557528 0.136378274 0.212248974 0.250443603 0.239973058 0.341927986 0.378867566 0.278575626 0.298866971 0.251310635 0.25147113];

T_train = [0.004749474 0.004906667 0.006703313 0.002257333 0.002533108 0.010816941 0.009142367 0.005037055 0.005767619 0.003008364 0.003651111 0.005619 0.003325818 0.001614194 0.006231611 0.007280622 0.015900014 0.005462801 0.011082758 0.013100739 0.013292323 0.01217091 0.0111332 0.007789229 0.007522472 0.012322123 0.005400399 0.005824971 0.014311411 0.011961137 0.022485539 0.011199144 0.018033758 0.020280868 0.019878343 0.020374429 0.017925359 0.012102891 0.014885847 0.019545302 0.012198029 0.013406449 0.012554624 0.009720887 0.011665018 0.008058492 0.010382035 0.012149144 0.01517445 0.016027216 0.01444982 0.009938811 0.013665846 0.014821038 0.010654038 0.009720438 0.040135654 0.038845935 0.042548553 0.032330928 0.045401446 0.028217936 0.026603914 0.027366947 0.044982863 0.036160721 0.047392765 0.047607038 0.035376514 0.035216066 0.027225248 0.039679443 0.031005953 0.047217 0.055648583 0.025470675 0.035274754 0.039376083 0.049283542 0.035413529 0.035184651 0.06307433 0.042144956 0.02904106 ...
0.055755741 0.084309431 0.052566774 0.053894066 0.068860072 0.073057813 0.092129292 0.082896605 0.083923453 0.061272559 0.076507886 0.075088686 0.055873645 0.04614525 0.065520014 0.116630832 0.082792218 0.093216739 0.087164016 0.084272499 0.093218219 0.071587817 0.108302945 0.058095544 0.068349428 0.072534823 0.064411513 0.07564202];

P_test = ;

T_test = ;%第一步,采用不同的网络结构训练,得到网络误差最小的一个网络结构
s=3:10;
res=1:8;
for i=1:8
net=newff(minmax(P_train),,{'tansig','tansig','purelin'},'traingdx');
net.trainparam.epochs=300;
net.trainparam.goal=0.0001
net=train(net,P_train,T_train)
y=sim(net,P_train);
error=y-T_train;
res(i)=norm(error);
end
no=find(res==min(res));
nunber=s(no)


%%第二步,用得到网络误差最小的一个网络结构,训练并模拟得到验证结果。
net=newff(minmax(P_train),,{'tansig','tansig','purelin'},'traingdx');
net.trainparam.epochs=400;
net.trainparam.goal=0.0001
net.trainparam.show=50;
net=train(net,P_train,T_train)
T_moni=sim(net,P_test)

[ 本帖最后由 eight 于 2008-4-28 18:28 编辑 ]
页: [1]
查看完整版本: 如何解决神经网络训练值为正但模拟值有负值的问题