close all
clear
echo on
正则化网络clc
% NEWFF——生成一个新的前向神经网络
% TRAIN——对 BP 神经网络进行训练
% SIM——对 BP 神经网络进行仿真
pause
% 敲任意键开始
clc
% 定义训练样本矢量
% P 为输入矢量
sqrs=[0.0000016420520 0.0000033513140 0.0000051272540 0.0000069694860 0.0000088776310 0.0000139339960 -0.0000594492310 -0.0001080022920 -0.0001476714860 ...
0.0000112367340 0.0002021567880 0.0008695337800 -0.0001189929700 -0.0000912336690 0.0002160472130 0.0006358522040 0.0012365884200 0.0049930394010 ]./0.001657904949 ;
sqjdcs=[0.0000399039272 0.0000805129702 0.0001218448339 0.0001639173001 0.0002067504102 0.0003172835720 0.0000421189848 0.0000870310694 0.0001350858140 ...
0.0001866997652 0.0002423599348 0.0004033628719 0.0000394450224 0.0000830935373 0.0001317612004 0.0001864881262 0.0002486249700 0.0004497441812 ]./0.000533286;
sqglmj=[0.0000068430669 0.0000147605347 0.0000240097285 0.0000349372747 0.0000480215187 0.0000954580176 0.0000005804238 0.0000011640375 0.0000017508228 ...
0.0000023407605 0.0000029338317 0.0000044301058 0.0000030813582 0.0000071511410 0.0000126615618 0.0000203910217 0.0000318028637 0.0001118629438 ]./0.000034868299 ;
s1=[0.0001773503110 0.0003553133430 0.0005338922010 0.0007130899610 0.0008929096590 0.0013452002950 0.0005747667510 0.0012111415700 0.0019195724060 ...
0.0027130110200 0.0036077110840 0.0064386221260 0.0005056929850 0.0010189193420 0.0015398201520 0.0020685403470 0.0026052286500 0.0039828224110 ]./0.00275071;
%s2=[25.9167875445 24.0718476818 22.2364947192 20.4105777318 18.5939487791 14.
0920619223 990.2535888432 1040.4661104131 1096.3830297389 1159.0297341398 ...
% 1229.6925839338 1453.3788619676 164.1136642277 142.4834641073 121.6137611080 101.4436832756 81.9180522413 35.6044841634];
glkyl=[1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3];
glhyl=[2 4 6 8 10 15 2 4 6 8 10 15 2 4 6 8 10 15 ];
P=[sqrs;sqjdcs;sqglmj;s1]; %输入数据矩阵
T=[glkyl;glhyl]; %目标数据矩阵
echo on
clc
pause
clc
% 创建一个新的前向神经网络
net=newff(minmax(P),[20,2],{'tansig','purelin'});
pause
clc
echo off
clc
disp('1. L-M 优化算法 TRAINLM'); disp('2. 贝叶斯正则化算法 TRAINBR');
choice=input('请选择训练算法(1,2):');
figure(gcf);
if(choice==1)
echo on
clc
% 采用 L-M 优化算法 TRAINLM
ainFcn='trainlm';
pause
clc
% 设置训练参数
ainParam.epochs = 500;
al = 1e-6;
net=init(net);
% 重新初始化
pause
clc
elseif(choice==2)
echo on
clc
% 采用贝叶斯正则化算法 TRAINBR
ainFcn='trainbr';
pause
clc
% 设置训练参数
ainParam.epochs = 500;
randn('seed',192736547);
net = init(net);
% 重新初始化
pause
clc
end
ainParam.epochs = 500;
al = 1e-6;
ainFcn='trainoss';
% 调用相应算法训练 BP 网络
[net,tr]=train(net,P,T);
pause
clc
% 对 BP 网络进行仿真
A = sim(net,P);
% 计算仿真误差
E = T - A;
MSE=mse(E)
pause
clc
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论