| Algorithm 1 A Brief Pseudo Code Function for the NN Training | |
| 1: | ////Output |
| 2: | function [imds,layers,options] = Experiment1_setup1(params) |
| 3: | /////Load Image Data |
| 4: | dataFolder |
| 5: | fullfile(‘C:\Users\H738\Desktop\XXXS\Experiment1\CH7_1\TEST’); |
| 6: | imds = imageDatastore(dataFolder, … |
| 7: | if ‘IncludeSubfolders’,true, … |
| 8: | ‘LabelSource’,‘foldernames’); |
| 9: | numTrainingFiles = 0.1; |
| 10: | [imds,imdsValidation] = splitEachLabel(imds,numTrainingFiles); |
| 11: | endif |
| 12: | ////Define Network Architecture |
| 13: | switch params.Network |
| 14: | case “alexnet” |
| 15: | load(‘AlexNet’,’layers_1’) |
| 16: | ///parameters announce |
| 18: | (inputSize; imds; imdsValidation;imdsValidation); |
| 19: | layers = layers_1; |
| 20: | case“googlenet” |
| 21: | load(‘GoogLeNet’,’lgraph_1’) |
| 22: | ///parameters announce |
| 23: | (inputSize; imds; imdsValidation;imdsValidation);; |
| 24: | layers = lgraph_1; |
| 25: | case“resnet101” |
| 26: | load(‘Resnet101’,’lgraph_2’) |
| 27: | ///parameters announce |
| 28: | (inputSize; imds; imdsValidation;imdsValidation);; |
| 29: | layers = lgraph_2; |
| 30: | otherwise |
| 31: | msg = [‘Undefined network selection.’ … |
| 32: | ‘Options are “default” and “googlenet” and “resnet101”.’]; |
| 33: | error(msg); |
| 34: | end |
| 35: | ///Specify Training Options |
| 36: | options = trainingOptions(params.Solver, … |
| 37: | ‘MiniBatchSize’,2280, … |
| 38: | ‘MaxEpochs’,50, … |
| 39: | ‘InitialLearnRate’,1 × 104, … |
| 40: | ‘Shuffle’,’every-epoch’, … |
| 41: | ‘ValidationData’,imdsValidation, … |
| 42: | ‘ValidationFrequency’,5, … |
| 43: | ‘ExecutionEnvironment’,“cpu”,… |
| ‘Verbose’,true, … | |
| ‘plots’,‘training-progress’); | |