📄 example26.m
字号:
%
%==============
%==============
figure('name','训练过程图示','numbertitle','off');
P=[1 1.5 1.2 -0.3; -1 2 3 -0.5; 2 1 -1.6 0.9];
T=[0.5 3 -2.2 1.4; 1.1 -1.2 1.7 -0.4; 3 0.2 -1.8 -0.4; -1 0.1 -1.0 0.6];
disp_freq=5;
max_epoch=str2num(max_epoch);
err_goal=str2num(err_goal);
lr=0.9*maxlinlr(P);
[R,Q]=size(P);
[S,Q]=size(T);
W=rands(S,R);
B=rands(S,1);
%calculate the error
SSE=sumsqr(T-purelin(W*P,B));
fprintf('Before training ,sum squared error=%g.\n',SSE)
%train the network
flops(0);
tp=[disp_freq max_epoch err_goal lr];
[W,B,epochs,errors]=trainwh(W,B,P,T,tp);
W;B;
SSE= sumsqr(T-purelin(W*P,B));
%show the results and the conclusions
ploterr(errors);
fprintf('\n After %0f epochs,sum squared error=%g.\n\n',epochs,SSE);
fprintf('Training took %0f flops.\n',flops);
fprintf('Trained network operates:');
if SSE < err_goal
disp('Adequately.')
else
disp('Inadequately.')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -