% Example Est.8.3 for Illustrating use of ANN for Nonlinear Data driven % Estimation % Programmed by B Joseph Washington University April 1993 % This requires use Neural Network Toolbox from Matlab % clc echo on clg % read data load ch19ex6_data est81=ch19ex6_data % split array into secondary and primary measurements % P=est81(:,1:4);P=P'; % This is the array of secondary measurements % each column of P represents one set of measurements T=est81(:,5);T=T'; % This is the row of compositions corresponding to each % set of secondary measurements % [R,Q]=size(P); S1=6; [S2,Q]=size(T); [W1,B1]=nwlog(S1,R); % random initialization of weights [W2,B2]=rands(S2,S1); % random initilizaiton disp_freq=500; % how often result is displayed max_epoch=5000; err_goal=.01; lr=0.01; momentum=.95; err_ratio=1.04; TP=[disp_freq max_epoch err_goal lr momentum err_ratio]; [W1,B1,W2,B2, epochs, TR]=trainbpm(W1,B1,'logsig',W2,B2,'purelin',P,T,TP); A1=purelin(W2*logsig(W1*P,B1),B2); plot(A1,T,'+',T,T); sse=norm(T-A1)^2;ssy=norm(T)^2;Rsquared=1-sse/ssy; sse,Rsquared load ch19ex6_test_data; est81=ch19ex6_test_data; % split array into secondary and primary measurements % P=est81(:,1:4);P=P'; % This is the array of secondary measurements % each column of P represents one set of measurements T=est81(:,5);T=T'; % This is the row of compositions corresponding to each A1=purelin(W2*logsig(W1*P,B1),B2); plot(A1,T,'+',T,T); sse=norm(T-A1)^2;ssy=norm(T)^2;Rsquared=1-sse/ssy; sse,Rsquared