You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUG Report]: Earlystopping should triger stopping the training if loss value is not improved by at least _min_delta.
[Suggestion]: I also suggest that the training should stop after loss reaches _base_line which should infer to the optimal value (the threshold to the desired loss value).
The fix for the bug is in line 134 in the file Tensorflow.Keras.Callbacks.EarlyStopping.cs: bool less_op = (monitor_value - _min_delta) < reference_value;
---> bool less_op = (monitor_value + _min_delta) < reference_value;
Why:
since _min_delta is always positive, and monitor_value is a slight improvement of reference_value, then (monitor_value - _min_delta) < reference_value will always be true. Therefore, it keeps resetting _wait to 0.
The suggestion to earlystopping using _baseline
The fix to the suggestion is in line 88 in the file Tensorflow.Keras.Callbacks.EarlyStopping.cs: if (_baseline == 0f || _is_improvement(current, _baseline))
---> if (_baseline == 0f || _is_improvement(_baseline, current))
Why:
We should check if the current improved loss is less than _baseline. If yes then do not reset _wait to 0.
Configuration and Other Information
No response
The text was updated successfully, but these errors were encountered:
Hello, very thanks for your suggestion. In TensorFlow.NET, it uses a single bool expression to represent self.monitor_op rather than np.greater and np.less that used in tensorflow. And it seems like the reason trigers this bug is that there lacks of parts corresponding to the following code in tensorflow:
Description
loss
value is not improved by at least_min_delta
.loss
reaches_base_line
which should infer to the optimal value (the threshold to the desired loss value).Reproduction Steps
Known Workarounds
Suggested fix to the bug
Tensorflow.Keras.Callbacks.EarlyStopping.cs
:bool less_op = (monitor_value - _min_delta) < reference_value;
--->
bool less_op = (monitor_value + _min_delta) < reference_value;
Why:
since
_min_delta
is always positive, andmonitor_value
is a slight improvement ofreference_value
, then(monitor_value - _min_delta) < reference_value
will always be true. Therefore, it keeps resetting_wait
to 0.The suggestion to earlystopping using _baseline
Tensorflow.Keras.Callbacks.EarlyStopping.cs
:if (_baseline == 0f || _is_improvement(current, _baseline))
--->
if (_baseline == 0f || _is_improvement(_baseline, current))
Why:
We should check if the current improved
loss
is less than_baseline
. If yes then do not reset_wait
to 0.Configuration and Other Information
No response
The text was updated successfully, but these errors were encountered: