Keras: EarlyStopping with restore_best_weights=True makes TypeError: 'NoneType' object is not subscriptable

Created on 29 Dec 2019  路  3Comments  路  Source: keras-team/keras

EarlyStopping with restore_best_weights=True makes TypeError: 'NoneType' object is not subscriptable.

When restore_best_weights=False no exception.

System information

  • Keras version: 2.3.1
  • Python version: 3.6

Stack trace:

  File "/.../.venv/lib/python3.6/site-packages/keras/engine/training.py", line 1239, in fit
    validation_freq=validation_freq)
  File "/.../.venv/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 216, in fit_loop
    callbacks.on_epoch_end(epoch, epoch_logs)
  File "/.../.venv/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 152, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "/.../.venv/lib/python3.6/site-packages/keras/callbacks/callbacks.py", line 834, in on_epoch_end
    self.model.set_weights(self.best_weights)
  File "/.../.venv/lib/python3.6/site-packages/keras/engine/network.py", line 516, in set_weights
    own_weights = weights[:num_param]
TypeError: 'NoneType' object is not subscriptable

Process finished with exit code 1

support

Most helpful comment

i have same problem

All 3 comments

i have same problem

Same problem running on Google Colab

Found the "problem".
It makes sense it is None because it found no better model than the baseline in my case.
I got rid of "baseline=1.0" and now it works.

Was this page helpful?
0 / 5 - 0 ratings