一个基于Levenberg-Marquardt算法的神经网络源程序
in=[ua';ub';ia';ib'];
out=[W'/200];
VV.P=[ua1';ub1';ia1';ib1'];
VV.T=[W1'/200];
[R,Q]=size(in);
S1=9;
S2=8;
S3=1;
net=newff(minmax(in),[S1 S2 S3],{'tansig' 'tansig' 'purelin'});%Levenberg-Marquardt法
% net=newff(minmax(x),[S1 S2 S3],{'tansig' 'tansig' 'purelin'},'trainlm');%Levenberg-Marquardt法
%训练参数的设计
net=init(net);
net.trainFcn= 'trainbr';
net.performFcn='sse';%性能函数
net.trainParam.goal=0.000001;%训练目标
net.trainParam.show=50;%每50步显示一次结果
net.trainParam.epochs=5000;
net.trainParam.max_fail=500;
net.trainParam.goal=0.00001 ;
net.trainParam.mu=0.055 ;
net.trainParam.mu_dec=0.1 ;
net.trainParam.mu_inc=1 ;
net.trainParam.mu_max=1e+10;
net.trainParam.mem_reduc=1 ;
net.trainParam.min_grad=1e-10;
[net,tr]=train(net,in,out);
save TrainedNN net; |