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

Can't pass arguments to PlotLossesKerasTF (figsize, fig_path) #110

Closed geoljogak closed 4 years ago

geoljogak commented 4 years ago

Issue: Can't pass arguments to PlotLossesKerasTF (figsize, fig_path) On: Windows 10, Python3.7.6, Tensorflow CPU 2.2.0, livelossplot 0.5.1 Get the following error.

TypeError Traceback (most recent call last)

in ----> 1 predictor.train(150,8) ~\training_imports.py in train(self, num_epochs, batch) 121 122 def train(self,num_epochs,batch): --> 123 lossplot = PlotLossesCallback(figsize=(15,7), fig_path=f'{self.filepath}loss_{self.timestamp}.png') C:\ProgramData\Miniconda3\envs\tf_cpu\lib\site-packages\livelossplot\inputs\tf_keras.py in __init__(self, **kwargs) 7 def __init__(self, **kwargs): 8 keras.callbacks.Callback.__init__(self) ----> 9 _PlotLossesCallback.__init__(self, **kwargs) C:\ProgramData\Miniconda3\envs\tf_cpu\lib\site-packages\livelossplot\inputs\generic_keras.py in __init__(self, **kwargs) 5 """Base keras callback class for keras and tensorflow.keras""" 6 def __init__(self, **kwargs): ----> 7 self.liveplot = PlotLosses(**kwargs) 8 9 def on_epoch_end(self, epoch, logs): C:\ProgramData\Miniconda3\envs\tf_cpu\lib\site-packages\livelossplot\plot_losses.py in __init__(self, outputs, mode, **kwargs) 19 :param kwargs: key-arguments which are passed to MainLogger 20 """ ---> 21 self.logger = MainLogger(**kwargs) 22 self.outputs = outputs if outputs is not None else [MatplotlibPlot(), ExtremaPrinter()] 23 for out in self.outputs: TypeError: __init__() got an unexpected keyword argument 'figsize'
stared commented 4 years ago

As of now, the correct way of passing is via MatplotlibPlot options, i.e.

from livelossplot import PlotLosses
from livelossplot.outputs import MatplotlibPlot, ExtremaPrinter

plotlosses = PlotLosses(outputs=[MatplotlibPlot(cell_size=(6, 4)), ExtremaPrinter()])

And same for PlotLossesKerasTF

Did it help?