stared / livelossplot

Live training loss plot in Jupyter Notebook for Keras, PyTorch and others
https://p.migdal.pl/livelossplot
MIT License
1.29k stars 143 forks source link

Bug with latest keras #108

Closed henrypinkard closed 4 years ago

henrypinkard commented 4 years ago

Trying to pass in the callback function gives:

AttributeError: 'PlotLossesCallback' object has no attribute '_implements_train_batch_hooks'

Can be fixed with:

plotter =  PlotLossesKeras()
plotter._implements_train_batch_hooks = lambda : True
plotter._implements_test_batch_hooks = lambda: True
plotter._implements_predict_batch_hooks = lambda: True

latest keras, lateest tensorflow, python3.6

stared commented 4 years ago

Could you please print the explicit versions AND exact lines how you import relevant Keras and TensorFlow functions?

In particular, are you sure you don't want to use PlotLossesKerasTF?

In any case, the https://github.com/stared/livelossplot/blob/master/livelossplot/inputs/generic_keras.py is very minimalistic, and only needs on_epoch_end in Keras Callbacks.

I checked the currents docs and it should work: https://keras.io/guides/writing_your_own_callbacks/. See also:

henrypinkard commented 4 years ago
import tensorflow as tf
import tensorflow.keras as keras
print(keras.__version__)
print(tf.__version__)

gives

2.3.0-tf
2.2.0

Python 3.6.10

Not sure. I just found out about your library and followed the example on this StackOverflow post. Doesn't matter to me since I got a hacked version working. Just wanted to report for the benefit of others who might be similarly confused

stared commented 4 years ago

Oh, I see. In your case

from livelossplot import PlotLossesKerasTF

should work. PlotLossesKeras is for bare Keras, i.e. one imported with import keras. Both Keras Callbacks are similar, but not the same - hence some possible issues.

I am happy you solved the problem anyway! :)