Solvedkeras AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

Please make sure that the boxes below are checked before you submit your issue. Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
  • If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

I am performing batch learning and after a few batches I get this error from this line of code:

model.fit(Xtrain, Ytrain, batch_size=128, nb_epoch=1,
                  verbose=1,validation_split=0.01,
                  callbacks=[ModelCheckpoint(weightStr, monitor='val_loss', verbose=0, save_best_only=True, mode='auto')])

Traceback (most recent call last):

  File "<ipython-input-1-0ab90ed05873>", line 321, in <module>
    callbacks=[ModelCheckpoint(weightStr, monitor='val_loss', verbose=0, save_best_only=True, mode='auto')])

  File "/home/kevin/.local/lib/python2.7/site-packages/keras/models.py", line 620, in fit
    sample_weight=sample_weight)

  File "/home/kevin/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1104, in fit
    callback_metrics=callback_metrics)

  File "/home/kevin/.local/lib/python2.7/site-packages/keras/engine/training.py", line 842, in _fit_loop
    callbacks.on_epoch_end(epoch, epoch_logs)

  File "/home/kevin/.local/lib/python2.7/site-packages/keras/callbacks.py", line 40, in on_epoch_end
    callback.on_epoch_end(epoch, logs)

  File "/home/kevin/.local/lib/python2.7/site-packages/keras/callbacks.py", line 196, in on_epoch_end
    self.progbar.update(self.seen, self.log_values, force=True)

AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

I have no idea why I get this error, It seems to happen randomly, can anyone point me in the right direction?

Here is the module of code that I am running:

for e in range(numEpoch):
    numOfImgToLoad = 50000#we can tune this
    totalNumberOfImages = len(imagesAndClass)
    runningTotal = 0
    startingPoint = 0
    endingPoint = numOfImgToLoad
    while totalNumberOfImages > 0:
        print "StartingPoint: {}, endingPoint {}".format(startingPoint, endingPoint)
        totalNumberOfImages = totalNumberOfImages - numOfImgToLoad#subtract the number of images loaded into mem
        if totalNumberOfImages < 0:
            remainder = totalNumberOfImages + numOfImgToLoad
            (Xtrain, Ytrain) = loadImages(imagesAndClass[startingPoint:remainder])
            Xtrain = np.array(Xtrain).reshape(len(Xtrain), 1, 106, 106)#np.array(Xtrain).reshape(4415, 1, 106, 106)
            runningTotal += remainder
        else:
            (Xtrain, Ytrain) = loadImages(imagesAndClass[startingPoint:endingPoint])
            Xtrain = np.array(Xtrain).reshape(len(Xtrain), 1, 106, 106)
            runningTotal += numOfImgToLoad
            startingPoint = endingPoint+1
            endingPoint = startingPoint + numOfImgToLoad - 1

        Xtrain /= 255#change pixel value to between 0 and 1
        Xtrain = Xtrain.astype('float32')
        Ytrain = np_utils.to_categorical(Ytrain, len(classes)+1)
        Ytrain = np.array(Ytrain)
        print "Starting epoch {}".format(e)
        model.fit(Xtrain, Ytrain, batch_size=128, nb_epoch=1,
                  verbose=1,validation_split=0.01,
                  callbacks=[ModelCheckpoint(weightStr, monitor='val_loss', verbose=0, save_best_only=True, mode='auto')])
                  #callbacks=[EarlyStopping(monitor='val_loss', patience=2)])
        #print "Starting epoch {} on image {}".format(e, runningTotal)
        print "Killing Xtrain and resetting"
        del Xtrain
        del Ytrain
32 Answers

✔️Accepted Answer

This happens if steps_per_epoch is 0. Make sure that your batch size is not greater than the dataset size to avoid it.

Other Answers:

Have you checked the dimensions for both ur x and y for train and test, I had a dimension issue with my y train. Generally the error arising if u tey to split data of incorrect size , say if it's 1, and u try to split it, it gives this error

I also encountered this error today. Had to set verbose=0 to fix.
Please reopen the issue. It needs to be fixed!

Encountered this error when my training set was an empty array. Using Keras 2.0.9.

A more descriptive error message might be helpful

For method fit() Keras should throw an exception when using validation_split and training set is ended up to be 0... Example: your last batch in epoch contains 1 sample and validation_split = 0.3 => training size = 0...
When training set size is 0 you will see this exception...
If you look at callbacks.py in keras, class ProgbarLogger, log_values member is created ONLY when batch starts... So if you don't have data in the batch it gets to on_epoch_end with log_values undefined...

Related Issues:

926
keras Loading model with custom loss function: ValueError: 'Unknown loss function'
I solved this problem by adding 'custom_bojects' my loss function: I trained and saved a model that ...
633
keras Tensorflow backend - bug in model._make_predict_function(...)
I had this problem when doing inference in a different thread than where I loaded my model ...
516
keras Creating Model variable throws "AttributeError: 'Tensor' object has no attribute '_keras_history'"
@zaid478 oh I assumed you were doing it on coursera Anyway Hello all setup: Keras 2.0 Tensorflow 1.0...
395
keras "<tensor> is not an element of this graph." when loading model.
I had a problem similar to that of @piraka9011 which was solved by calling model._make_predict_funct...
204
keras Quick Question: can a model be fit for multiple times?
Yes successive calls to fit will incrementally train the model. I'm now having something around 5000...
183
keras Error when checking model target: expected activation_2 to have shape (None, 10) but got array with shape (3, 1)
Your model has an output of shape (10,) however your outputs have dimension (1,) You probably want t...
178
keras Is there a way in Keras to apply different weights to a cost function?
Ok so I had the time to quickly test it Hi there I am trying to implement a classification problem w...
172
keras Keras model cannot be loaded if it contains a Lambda layer calling tf.image.resize_images
Try using custom_objects argument in load_model (or model_from_json) function For your case load_mod...
164
keras how to use fit_generator with multiple image inputs
Thanks Here is how I solved it following some ideas from issue 3386 maybe someone might find it usef...
151
keras Expected 3 dimensions but got array with shape (11, 2)
The problem is that you start with a three dimensional layer but never reduce the dimensionality in ...
148
keras AttributeError: 'ProgbarLogger' object has no attribute 'log_values'
This happens if steps_per_epoch is 0 Make sure that your batch size is not greater than the dataset ...
147
keras For large datasets, which to use: fit or train_on_batch?
I think the best way to fit large data which can not fit into memory is writing a customize generato...
147
keras Split train data into training and validation when using ImageDataGenerator and model.fit_generator
I just found this in the documentation given here Its okay if I am keeping my training and validatio...
145
keras using pre trained VGG16 for another classification task
One way to do this is to not include the fully-connected layers at the top of the network Then add n...
123
keras "Merge" versus "merge", what is the difference?
Merge is a layer Merge takes layers as input Merge is usually used with Sequential models merge is a...
115
keras load_model() with custom layers, and custom layers in general
For the people landing here by a Google search the code we should use: as can be found on kapre's Gi...
108
keras Retrained MobileNet and failed to load it for prediction
Just to make @fchollet's comment explicit for fellow n00bs like me...this works: ...
107
keras How does Embedding Layer work?
GloVe and word2vec DO NOT convert a word to an integer I'm curious about how embedding layers work E...
105
keras Running tensorflow backend on single gpu but on multi gpu machine
This is default behavior for TensorFlow If you want TensorFlow to not allocate memory for all of the...
105
keras TypeError: softmax() got an unexpected keyword argument 'axis'
Hi I get the same problem but I got a better solution Just downgrade the tensorflow and keras My pre...
101
keras Passing additional arguments to objective function
@rpinsler actually doing a closure in the manner you suggested seems to work (thanks!) ...
96
keras Option for using dropout in the predict phase (as an approximation to Bayesian DL)
There is this feature in Keras: it's the training argument in the call of the Dropout layer ...
89
keras loss function for multi-label problem
categorical_crossentropy: 1-of-N (one-hot) binary_crossentropy: 1-or-more 0/1 labels ...
87
keras Convert Keras model to TensorFlow
When you are using the TensorFlow backend your Keras code is actually building a TF graph You can ju...
82
keras experimental_list_devices in tensorflow_backend.py (line 506)
I solve this by installing an older version which version of Keras is downgraded? and which version ...
82
keras Removing layers with layers.pop() doesn't work?
I actually ran into this recently and I believe that this is an issue with how Model was rewritten t...
78
keras A concrete example for using data generator for large datasets such as ImageNet
I have some follow up questions @wongjingping : Response to 3 I should have been clearer I am not co...
72
keras ImportError: No module named h5py
Have you tried directly installing h5py? http://docs.h5py.org/en/latest/build.html Try running pip i...
71
keras Variable-size image to convolutional layer
You should use: input_shape=(1 None None) None in a shape denotes a variable dimension Note that not...
71
keras val_acc KeyError using ModelCheckpoint.
Use val_loss in place of val_acc otherwise for accuracy Use val_accuracy in place of val_acc ...
69
keras Combining Pretrained model with new layers
Okay @Vijethbv first of all the error that is raised is due to a misspelling It's model.layers with ...
67
keras LSTM/RNN input and output
For a feed-forward network your input has the shape (number of samples number of features) With an L...
64
keras Attention Mechanism Implementation Issue
@zzjin13 Here you go. Hope it helps. The problem is that I have an output a from a LSTM layer with t...
64
keras Each time I run the Keras, I get different result.
by default Keras's model.compile() sets the shuffle argument as True You should the set numpy seed b...
60
keras Callback self.validation_data is None, when fit_generator is used
I am facing the same issue too But when I look into the source codes of Keras Related: #2702 Check t...
60
keras ImageGenerator for multiple inputs
Ok I made it work! For anybody asking himself the same question here is my example solution: ...
51
keras Does Keras support using multiple GPUs?
Yes can run Keras models on multiple GPUs This is only possible with the TensorFlow backend for the ...
50
keras How to implement my own loss function?
(Copying the answer which I posted on Stackoverflow) http://stackoverflow.com/questions/33859864/how...
49
keras 'thread._local' object has no attribute 'value' error
I'm using keras 2.3.1 tensorflow 2.0.0 python 3.6 linux Mint 19.2 Cinnamon My project is based on Wa...
48
keras how to load weights trained on multi gpu model to the single gpu model?
@smthomas-sci Custom model checkpoint callback works very well The problem is that if I only have a ...
47
keras AttributeError: module 'pydot' has no attribute 'find_graphviz'
pydot-ng will give you pydot that satisfies the keras package use pip install pydot-ng to install it...
47
keras Unable to Load Custom Objectives from an H5 Model File
@StuartFarmer did you find a solution to your problem? all I had to do was to use load_model like be...
46
keras How to use a tensorflow metric function in keras?
For now it's sufficient to add variables created for some tf metric to GraphKeys.GLOBAL_VARIABLES co...
45
keras Confusion regarding class_weight
I have this simple function for computing the weights for each class: What i do is pick the majority...
43
keras Can't load_model with error “Optimizer weight shape (256, 32) not compatible with provided weight shape (4,)”
I am using Keras 1.1.1 and am having the same problem Deleting the optimizer weights as a workaround...
41
keras memory leak when using tensorflow
You can now use K.clear_session() when using TensorFlow which will clean up everything This is recom...
41
keras Generalized dice loss for multi-class segmentation
Hey guys I found a way to implement multi-class dice loss I get satisfying segmentations now ...
39
keras How to get learning rate during training ?
Use callback to access model.optimizer Notice: It only works for SGD If you want to do the same thin...