ANN_REPET — Function to train different repetitions of a feed-forward artificial neural network with a split sample test procedure.
[W,OUT,C,RMSE,[IN_Stat,TARG_Stat,RMSErepet,Wrepet,OUTrepet]]=ANN_REPET(IN,TARG,Nhid,ChemRAND,[NbRepet,EPOCH,calP3,BEG_END,SIGFACT])
Input data (matrix [PxN] where P is the number of input neurons and N the number of input patterns)
Target data (matrix [1xP]). CAUTION ! This function only works with one output !!
Number of neurons in the hidden layer
Complete path of the text file containing the random numbers matrix. CAUTION ! These numbers should be in the [0..1] interval !
Number of repetitions (should be >2). Default = 10
Number of epochs (should be >2). Default = 30
Defines if ANN are calibrated on P3 or not (default = %F)
Defines the beginning and end of P1 and P2. BEG_END = [[begP1;endP1],[begP2;endP2]];
Defines the multiplicator applied on standard deviation to normalize input data (default = 1).
Final weight and biais values (Matrix [NPx3] where NP is the number of network parameters stored in vector format, see ANN_CONV_W). W(:,1) = parameters resulting from a calibration on the first half of the dataset (P1).
W(:,2) = parameters resulting from a calibration on the second half of the dataset (P2).
W(:,3) = parameters resulting from a calibration on the whole dataset (P3).
Final network outputs (Matrix [Nx4] where N is the number of patterns). OUT(:,1) = output resulting from a calibration on P1.
OUT(:,2) = output resulting from a calibration on P2.
OUT(:,3) = output resulting from a calibration on P3.
OUT(:,4) = output in validation mode (parameters from P2 are applied on P1 and vice-versa).
Quality criteria of the simulation (CRIT function).
C(:,per) : Criteria on calibrated simulation on per (=1,2,3)
C(:,4) : Criteria on simulation in validation mode
Root Mean square error of calibrated output on the 3 sub-periods (Matrix [3x1]).
RMSE(1) = RMSE resulting from a calibration on P1.
RMSE(2) = RMSE resulting from a calibration on P2.
RMSE(3) = RMSE resulting from a calibration on P3.
Values used for input normalisation (Matrix [2P x 3]). The first P lines are the means and the following P lines are the standard deviations. Each columns is dedicated to a sub-period (P1, P2 and P3).
Values used for target normalisation (Matrix [2 x 3]). The first line is the mean and the second line is the standard deviation. Each columns is dedicated to a sub-period (P1, P2 and P3).
Root Mean square error of calibrated output on the 3 sub-periods for all the repetitions (Matrix [NbRepet x 3]).
Neural network weights and biases for the 3 sub-periods and all the repetitions (Matrix [NP x NbRepet x 3]).
Neural network outputs for the 3 sub-periods and all the repetitions (Matrix [N x NbRepet x 3]).
The function performs the following actions:
(0) Inputs AND outputs are normalised by their mean and 2 x standard deviation (to keep generalisation capacity on extremas).
(1) The dataset is split into 2 equal parts, P1 and P2. P3 represents the whole dataset.
(2) On each sub-period, a neural network is calibrated with a Levenberg-Marquardt algorithm (with bayesian regulation, see ANN_LMBR).
(3) This calibration is repeated NR times with NR the number of repetitions. Each calibration starts from a different and randomly defined initial parameter set (weight only, all biaises are set to 0). This leads to 3*NR parameters sets.
(4) For each sub-period, a median simulation is calculated from the NR outputs generated by the NR calibrations realised in step 3 (Median simulation = simulation constituted with median values of the NR simulation at each points of the dataset). This leads to 3 simulations (one for each sub-period)
(5) For each sub-period, The simulation showing the highest similarity with the median simulation is selected as the "best repetition" (similarity on the basis of smallest RMSE). This leads to 3 parameters sets (one for each sub-period).
(6) Parameters of this "best simulation" are returned and validation criteria are calculated (parameters from P2 are applied on P1 and vice-versa to get a complete simulation).
// Calibration of a network with 6 input nodes, 4 nodes in the hidden layer and 1 output node IN = [(1:0.05:10);sin(1:0.05:10)]+rand(2,181); TARG = abs((1:0.05:10).^0.01+(sin(1:0.05:10)).^0.5)+rand(1,181); Nhid = 4; // Print a random number matrix ChemRAND = TMPDIR+'/randMat.txt'; fprintfMat(ChemRAND,rand(1000000,1),'%5.4f'); // Calibration on P1, P2 and P1+P2 with 4 hidden nodes [W,OUT,C,RMSE] = ANN_REPET(IN,TARG,Nhid,ChemRAND,'def','def',%t); // Delete the random number matrix mdelete(ChemRAND); // Graph >> goog calibration but validation problems on this example ! x=(1:size(OUT,1))'; plot(x,TARG','k:',x,OUT); legend(['Observed data' 'Calibration on P1' 'Calibration on P2' 'Calibration on P3' 'Validation'],a=4,%f);