简单的、用于简单数据学习的BP人工神经网络

下面是一个简单的BP人工神经网络的例子,用matlab工具箱实现。

clc
%输入变量
sqrs=[0.110027 0.063019 0.105534 0.129025 0.157431 0.231472 0.092534 0.18466 0.101555 0.064493];%GDP
sqjdcs=[0.117404 0.113465 0.074107 0.371856 0.223811 0.183649 0.078254 0.171919 0.057375 0.023523];%贸易增长率
sqglmj=[510610 561100 617150 678947 740940 805370 868880 929340 984610 103260];%移民
banquan=[2930 3983 4700 5691 7783 9365 10401 10293 10471 11133];
tushuchukou=[740 802 885.16 945.64 1144.18 2061.77 1992.86 1689.42 1552.63 1493];
youke=[472 610 789 1022 1322 1710 2213 2863 3704 4792];
%输出变量
%glkyl=[0.53724 0.46553 0.39716 0.33198 0.26983 0.21059 0.15411 0.10027 0.04894 0.00547];
glkyl=[12.0127 16.0014 20.0065 23.3646 25.2955 25.0689 22.2091 16.6766 8.9552 1.0498];%million
glhyl=[1237 1379 1385 1399 1663 1714 1834 4322 8132 8936];
p=[sqrs;sqjdcs;sqglmj;banquan;tushuchukou;youke];
t=[glkyl;glhyl];

[pn,minp,maxp,tn,mint,maxt]=premnmx(p,t);
dx=[-1,1;-1,1;-1,1;-1,1;-1,1;-1,1];

net=newff(dx,[6,36,2],{'tansig','tansig','purelin'},'traingdx');

net.trainParam.show=1000;
net.trainParam.Lr=0.05;
net.trainParam.epochs=50000;
net.trainParam.goal=0.65*10^(-3);
net=train(net,pn,tn);
%和原始数据进行对比
an=sim(net,pn);
a=postmnmx(an,mint,maxt);

x=(1999:2:2017);
newk=a(1,:);
newh=a(2,:);
figure(2);
subplot(2,1,1);plot(x,newk,'r-o',x,glkyl,'b--+');
legend('the result of learning','original data');
xlabel('year');ylabel('polulation/million');
title('population of the chinese speaker');
subplot(2,1,2);plot(x,newh,'r-o',x,glhyl,'b--+');
legend('666','777');
xlabel('888');ylabel('999');
title('000');
%预测
pnew=[3504091 15019105
      564241.8 814241.8
      2042466 4660125
      30000 45000
      1023.35 1021.33
      100000 100000];
pnewn=tramnmx(pnew,minp,maxp);
anewn=sim(net,pnewn);
anew = postmnmx(anewn,mint,maxt)

运行时出现了点问题,虽然能比较好的拟合原数据,但是对于matlab提醒的警告还是不明所以,望赐教!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值