2020-02-11 04:55:22 +00:00
|
|
|
Early stopping
|
2020-02-18 16:25:39 +00:00
|
|
|
==============
|
2020-02-11 04:55:22 +00:00
|
|
|
|
2020-02-18 16:25:39 +00:00
|
|
|
Default behavior
|
|
|
|
----------------
|
|
|
|
By default early stopping will be enabled if `'val_loss'`
|
2020-03-06 00:31:57 +00:00
|
|
|
is found in `validation_epoch_end()` return dict. Otherwise
|
2020-02-18 16:25:39 +00:00
|
|
|
training will proceed with early stopping disabled.
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
Enable Early Stopping
|
2020-02-18 16:25:39 +00:00
|
|
|
---------------------
|
2020-02-11 04:55:22 +00:00
|
|
|
There are two ways to enable early stopping.
|
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`trainer`
|
2020-02-11 04:55:22 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
2020-02-18 16:25:39 +00:00
|
|
|
# A) Set early_stop_callback to True. Will look for 'val_loss'
|
2020-03-06 00:31:57 +00:00
|
|
|
# in validation_epoch_end() return dict. If it is not found an error is raised.
|
2020-02-11 04:55:22 +00:00
|
|
|
trainer = Trainer(early_stop_callback=True)
|
|
|
|
|
|
|
|
# B) Or configure your own callback
|
|
|
|
early_stop_callback = EarlyStopping(
|
|
|
|
monitor='val_loss',
|
|
|
|
min_delta=0.00,
|
|
|
|
patience=3,
|
|
|
|
verbose=False,
|
|
|
|
mode='min'
|
|
|
|
)
|
|
|
|
trainer = Trainer(early_stop_callback=early_stop_callback)
|
|
|
|
|
2020-02-18 16:25:39 +00:00
|
|
|
Disable Early Stopping
|
|
|
|
----------------------
|
|
|
|
To disable early stopping pass ``False`` to the `early_stop_callback`.
|
|
|
|
Note that ``None`` will not disable early stopping but will lead to the
|
|
|
|
default behaviour.
|
2020-02-11 04:55:22 +00:00
|
|
|
|
2020-03-15 23:46:39 +00:00
|
|
|
.. seealso:: :ref:`trainer`
|