Is trainNetwork early stopping behavior wrong?

13 ビュー (過去 30 日間)
Adriano Moutinho
Adriano Moutinho 2021 年 8 月 8 日
回答済み: Lorenzo Cremonini 2021 年 11 月 28 日
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...

回答 (1 件)

Lorenzo Cremonini
Lorenzo Cremonini 2021 年 11 月 28 日
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

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by