Is trainNetwork early stopping behavior wrong?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I decided to use validation and early stop to avoid overfitting. This is a classic feature in neural network training. So, everything is set like this:
options = trainingOptions('adam', ...
... other options...
'ValidationFrequency', 1, ...
'ValidationData', {XVAL, YVAL}, ...
'ValidationPatience', 25, ...
);
XVAL and YVAL are part of my database used specifically for validation. I train the network with data from XTRAIN and YTRAIN:
trainNetwork (XTrain, YTrain, layers, options);
But the problem is that although the early stop works well, stopping when validation has no gain for more than 25 epochs, as I configured in "ValidationPatience" trainingOptions, instead of going back to the epoch with the best LOSS obtained during training, the output network returned by trainNetwork is the one from last epoch!
So I ended up with a network trained with 25 epochs after the best result!
Is this is wrong? How can I fix this? I used verbose "on" to be sure about the results. I'm definitely getting the last epoch network, 25 epochs after the best validation result is found...
0 comentarios
Respuestas (1)
Lorenzo Cremonini
el 28 de Nov. de 2021
Hi,
For what you want to obtain, you need to add another option in trainingOptions, that is “OutputNetwork”, “best-validation-loss”
Hoping it helps.
LC
0 comentarios
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!