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

KeyError : 'metrics' Please Help #104

Closed hemangjoshi37a closed 4 years ago

hemangjoshi37a commented 4 years ago

This error has started appearing after I upgraded my tensorflow version to 2.2

~/.local/lib/python3.5/site-packages/livelossplot/generic_keras.py in on_train_begin(self, logs) 29 30 def on_train_begin(self, logs={}): ---> 31 self.liveplot.setmetrics([metric for metric in self.params['metrics'] if not metric.startswith('val')]) 32 33 # slightly convolved due to model.complie(loss=...) stuff

KeyError: 'metrics'

kaanakdeniz commented 4 years ago

If you should import just keras import keras it'll work. I don't know why but tensorflow keras is not working. And you should from livelossplot.keras import PlotLossesCallback model.fit callback = callbacks=[PlotLossesCallback()])

stared commented 4 years ago

@hemangjoshi37a Coul you post the lines of code causing this error?

hemangjoshi37a commented 4 years ago

This is the code sir... @stared

model.compile(optimizer=keras.optimizers.adam(), loss='mean_squared_error',metrics=["accuracy"])
history=model.fit(x_train, y_train,validation_split=0.05, verbose=1, batch_size=1000, epochs=5,callbacks=[livelossplot.PlotLossesKeras(),WandbCallback()])
hemangjoshi37a commented 4 years ago

If you should import just keras import keras it'll work. I don't know why but tensorflow keras is not working. And you should from livelossplot.keras import PlotLossesCallback model.fit callback = callbacks=[PlotLossesCallback()])

@kkanska I cant use keras instead of the tfkeras because it does not work with my other code. So it is not a option. But anyway sir thank you very much for replying.

stared commented 4 years ago

@hemangjoshi37a Could you copy&paste all import lines (relevant to livelossplot, Keras and TensorFlow)?

megha-a7 commented 3 years ago

I was still getting the error. Then I followed this -

I did import keras

Then changed the import statement

from livelossplot.tf_keras import PlotLossesCallback to

from livelossplot.inputs.tf_keras import PlotLossesCallback

stared commented 3 years ago

@megha-a7 Please show the full part with the import and versiona of TensorFlow and Keras.

If you use standalone keras, you need to use livelossplot.keras, not livelossplot.tf_keras.