📄 test5.m
字号:
% DEMONSTRATION PROGRAM FOR TESTING NNOE
%
% Programmed by Magnus Norgaard, IAU/IMM/EI, Technical Univ. of Denmark
% LastEditDate: Aug 21, 1995
close all
StopDemo=0;
figure
guihand=gcf;
for k=1:1, %dummy loop
% >>>>>>>>>>>>>>>> BUILD GUI INTERFACE <<<<<<<<<<<<<<<<<
[guihand,edmulti,contbut,quitbut]=pmnshow;
set(guihand,'Name','NNOE demonstration');
% >>>>>>>>>>>>>>>> SCREEN 1 <<<<<<<<<<<<<<<<<
s0='1';
s1='The purpose of this demo is to show how the NNOE';
s2='function can be used for modelling a second order';
s3='nonlinear dynamic system.';
s4=[];
s5='To generate the model we will use the noise corrupted';
s6='data set shown above.';
smat=str2mat(s0,s1,s2,s3,s4,s5,s6);
load spmdata
subplot(411)
plot(u1);
title('Input and output sequence')
subplot(412)
plot(y1);
pmnshow(smat,guihand,edmulti,contbut,quitbut);
if StopDemo==1, close all, break; end
% >>>>>>>>>>>>>>>> SCREEN 2 <<<<<<<<<<<<<<<<<
s0='2';
s1='First we have to select a model structure inside';
s2='which we wish to search for a good model.';
s3=[];
s4='The model structure selection consists of two';
s5='subproblems: Choosing a regressor structure and';
s6='choosing a network architecture.';
smat=str2mat(s0,s1,s2,s3,s4,s5,s6);
pmnshow(smat,guihand,edmulti,contbut,quitbut);
if StopDemo==1, close all, break; end
% >>>>>>>>>>>>>>>> SCREEN 3 <<<<<<<<<<<<<<<<<
subplot(411);delete(gca);subplot(412);delete(gca)
subplot('position',[0.1 0.5 0.6 0.5])
W1=rand(5,5);
W2=rand(1,6);
drawnet(W1,W2,eps,['yhat(t-1)';'yhat(t-2)';' u(t-1)';' u(t-2)'],'yhat(t)');
s0='3';
s1='As regressors we will use two past inputs and';
s2='two past outputs.';
s3=[];
s4='Furthermore we will choose a network architecture';
s5='with 5 hidden ''tanh'' units and one linear output unit.';
smat=str2mat(s0,s1,s2,s3,s4,s5);
pmnshow(smat,guihand,edmulti,contbut,quitbut);
if StopDemo==1, close all, break; end
% >>>>>>>>>>>>>>>> SCREEN 4 <<<<<<<<<<<<<<<<<
s0='4';
s1='Now that a model structure has been selected, we are';
s2='ready to begin training.';
s3=[];
s4='Let''s run the NNOE function, which uses a Levenberg-';
s5='Marquardt algorithm for generating an Output Error model.';
smat=str2mat(s0,s1,s2,s3,s4,s5);
% ----- Choose training parameters -----
maxiter = 100;
stop_crit=1e-4;
lambda=1;
D=1e-4;
NetDef = ['HHHHH'
'L----'];
NN = [2 2 1];
trparms=[maxiter stop_crit lambda D];
pmnshow(smat,guihand,edmulti,contbut,quitbut);
if StopDemo==1, close all, break; end
% >>>>>>>>>>>>>>>> SCREEN 5 <<<<<<<<<<<<<<<<<
% ----- Train network -----
s0='5';
s1=[];
s2=' >> Training process in action!! <<';
s3=[];
s4=[];
s5='We run up to 100 iterations so you may have to';
s6='wait for a while.';
smat=str2mat(s0,s1,s2,s3,s4,s5,s6);
set(edmulti,'String',smat);
drawnow
[W1,W2,NSSEvec,iter,lambda]=nnoe(NetDef,NN,[],[],trparms,10,y1,u1);
delete(gca);
subplot('position',[0.1 0.55 0.45 0.38]);
semilogy(NSSEvec);
xlabel('Iteration');
ylabel('Criterion of fit');
grid
% >>>>>>>>>>>>>>>> SCREEN 6 <<<<<<<<<<<<<<<<<
% ----- Evaluate network -----
s0='6';
s1='The network has now been trained and we conclude';
s2='the session by validating the model on a fresh';
s3='data set.';
smat=str2mat(s0,s1,s2,s3);
pmnshow(smat,guihand,edmulti,contbut,quitbut);
if StopDemo==1, close all, break; end
[Yhat,PI_vector]=nnvalid('nnoe',NetDef,NN,W1,W2,y2,u2);
figure(1)
% >>>>>>>>>>>>>>>> SCREEN 7 <<<<<<<<<<<<<<<<<
s1=[];
s2=' >> THE END <<';
smat=str2mat(s1,s1,s1,s1,s2);
set(edmulti,'String',smat);
drawnow
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -