Giter Club home page Giter Club logo

Comments (4)

stared avatar stared commented on August 29, 2024

@KhondokerIslam Could you write the code and full error message?

from livelossplot.

loic-cgi avatar loic-cgi commented on August 29, 2024

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'

from livelossplot.

loic-cgi avatar loic-cgi commented on August 29, 2024

I got this problem solved by reinstalling tensorflow and restarting my notebook

from livelossplot.

stared avatar stared commented on August 29, 2024

Great @loic-cgi !

Also, check out the next version 0.5.0 as there are new changes.

from livelossplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.