|
|
Algorithm Pseudo Code for Estimating an Optimal Configuration for n hidden layers |
|
| arrsizes =emptyList([]) |
| niter = n
|
| for i ← [1,2,..niter] do
|
| for numNeurons = 5;numNeurons+= 5;numNeurons≤ 1000 do
|
| for
kfold in 10 fold Cross Validation do
|
| models←MLPClassifier(hiddenLayerSizes=arrsizes.append(numNeurons), activation =‘ReLu’, solver=‘Adam’, maxIterations=1000) |
| {Now train on k-1 folds and test on kth fold} |
| model.fit([1fold, 2fold, …k – 1fold], trainLabels) |
| {Add all confusion matrices for k-folds} |
| confusionMatrix←confusionMatrix+confMat(testLabels, model.predict(kth fold)) |
| end for
|
| {Store the number of neurons for which we have the maximum f1 score} |
| if confusionMatrix.f1 > max f1
then
|
| max f1 ←confusionMatrix.f1
|
| bestNumNeurons← numNeurons |
| end if
|
| end for
|
| arrsizes[i]←bestNumNeurons |
| end for
|
|