|
Algorithm 2. The Matlab code for training multiple ANN system |
| % - input matrix 96 × 50000 of training cases |
| % - output matrix 2883 × 50000 of training cases |
| % Choose a Training Function |
|
trainFcn = 'trainlm'; % In this case Levenberg-Marquardt backpropagation was chosen |
|
hiddenLayerSize = 10; % Choose a number of hidden layers |
|
net = fitnet(hiddenLayerSize,trainFcn); % Create a fitting network under variable ‘net’ |
| % Choose input and output pre/post-processing functions |
| % ‘removeconstantrows’ - remove matrix rows with constant values |
| % ‘mapminmax’ - map matrix row minimum and maximum values to [−1 1] |
|
net.input.processFcns = {'removeconstantrows','mapminmax'}; |
|
net.output.processFcns = {'removeconstantrows','mapminmax'}; |
| % Setup division of data for training, validation, testing |
|
net.divideFcn = 'dividerand'; % Divide data randomly |
|
net.divideMode = 'sample'; % Divide up every sample |
|
net.divideParam.trainRatio = 70/100; % 70% of cases is allocated for training |
|
net.divideParam.valRatio = 15/100; % 15% of cases is allocated for validation |
|
net.divideParam.testRatio = 15/100; % 15% of cases is allocated for testing |
|
net.performFcn = 'mse'; % Mean Squared Error will be used for performance evaluation |
|
x = X'; |
|
y = Y'; |
|
N=2883; % The resolution of output picture grid |
|
parfor i=1:N % Start ‘for’ loop with parallel computing |
| % Assign an i-th row of reference cases to the variable t. Each of the 2883 lines corresponds |
| % to one pixel of the output image |
| t = y(i,:); |
| % Train the network. The variable ‘nets_for_pixels’ is a structure that consists of 2883 |
| % separately trained neural networks. |
| [nets_for_pixels{i},~] = train(net,x,t); |
|
end % End ‘parfor’ loop |