Closed KhondokerIslam closed 4 years ago
@KhondokerIslam Could you write the code and full error message?
I get the same error
Code:
# imports
# this is to keep saving and load the best model
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.models import load_model
# this is to build the layers of the models
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.models import Sequential
# import for live loss plot
from livelossplot.tf_keras import PlotLossesCallback
# the optimiser that optimises the loss function
from tensorflow.keras.optimizers import Adam
# initialise checkpoint (for saving models)
checkpoint = ModelCheckpoint('modelsNLP/model_dense.h5', verbose=1, monitor='val_acc',
save_best_only=True, mode='auto')
# model architecture
model = Sequential()
model.add(Dense(128, activation='relu', input_shape=X_train.shape[1:]))
model.add(Dropout(0.5))
model.add(Dense(Y_train.shape[1], activation='softmax'))
model.compile(loss='categorical_crossentropy',
optimizer=Adam(amsgrad=True, clipnorm=1),
metrics=['accuracy'])
history = model.fit(X_train, Y_train, epochs=250,
batch_size=256, validation_split=0.2,
callbacks=[checkpoint, PlotLossesCallback()], verbose=1)
Error message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-46-779bc51c19f1> in <module>
24 history = model.fit(X_train, Y_train, epochs=250,
25 batch_size=256, validation_split=0.2,
---> 26 callbacks=[checkpoint, PlotLossesCallback()], verbose=1)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
778 validation_steps=validation_steps,
779 validation_freq=validation_freq,
--> 780 steps_name='steps_per_epoch')
781
782 def evaluate(self,
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py in model_iteration(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq, mode, validation_in_fit, prepared_feed_values_from_dataset, steps_name, **kwargs)
237
238 callbacks.model.stop_training = False
--> 239 callbacks._call_begin_hook(mode)
240 progbar.on_train_begin()
241
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\callbacks.py in _call_begin_hook(self, mode)
260 """Helper function for on_{train|test|predict}_begin methods."""
261 if mode == ModeKeys.TRAIN:
--> 262 self.on_train_begin()
263 elif mode == ModeKeys.TEST:
264 self.on_test_begin()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\callbacks.py in on_train_begin(self, logs)
376 """
377 for callback in self.callbacks:
--> 378 callback.on_train_begin(logs)
379
380 def on_train_end(self, logs=None):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\livelossplot\generic_keras.py in on_train_begin(self, logs)
60
61 self.liveplot.metric2title = metric2printable_updated
---> 62 self.liveplot.set_max_epoch(self.params['epochs'])
63
64 def on_epoch_end(self, epoch, logs={}):
AttributeError: 'PlotLosses' object has no attribute 'set_max_epoch'
I got this problem solved by reinstalling tensorflow and restarting my notebook
Great @loic-cgi !
Also, check out the next version 0.5.0 as there are new changes.
Hi,
I am trying to use this library but the following error of no "set_max_epoch" attribute is showing. Thanks.