continuetrainblueestimate.m

来自「matlab使用BP网络的例子,使用Levenberg Marquardt算法提」· M 代码 · 共 24 行

M
24
字号
%当训练评估过程trainBlueEstimation.m被中断后继续训练的代码

clear;
load state.mat;              %载入原来的训练情况
nown=n+1;
for n=nown:samplenum-1                                  %抽样训练
    net=init(net);                                      %为了更好的性能,,需要随机的初始化函数
	[net,tr]=train(net,TrainingSample(:,1:n),TrainingObject(:,1:n));
	prediction=sim(net,TrainingSample(:,n+1));    %预测值
	real=TrainingObject(:,n+1);                   %目标值
    MSE=tr.perf(size(tr.perf,2));                   %计算性能    
	if(abs(prediction-real)<0.6)                    %计算正确率
        correctnum=correctnum+1;
	end;
	if(GoodMSE>MSE)                                 %得到一个更好的网络
        save GoodBlueNetwork.txt net MSE pn tr n correctnum;    %训练过程要存下来
        GoodMSE=MSE;
	end;
    save state.mat;                                 %每做完一次训练后保存一次以便将来能继续
    save n.txt n MSE correctnum -ascii;                        %可以让我们看出当前训练到哪一步了,MSE是多少,预测能力是多少
end
num=samplenum-200;
ratio=correctnum/num;                               %正确率
save ratio.txt ratio -ascii;                        %记录正确率

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?