0
votes

I am trying to build CNN but having attribute error AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

Here is the code

model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv2D(16,(3, 3), activation = 'relu', padding = 'valid', input_shape = (28, 28, 1)))
model.add(tf.keras.layers.MaxPooling2D(pool_size = (2, 2)))
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(100, activation = 'relu'))
model.add(tf.keras.layers.Dense(10, activation = 'softmax'))

# learning rule
optimizer = tf.keras.optimizers.SGD(lr = 0.1, decay = 1e-6, momentum = 0.9, nesterov = True)

# Loss function
model.compile(loss = 'categorical_crossentropy',
              optimizer = optimizer,
              metrics = ['accuracy'])
print(model.summary())


history = History()
model.fit(X_train, Y_train, batch_size = 64, epochs = 20, validation_split = 0.1, callbacks = [history])
score = model.evaluate(X_test, Y_test, verbose = 0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
plt.plot(history.history['accuracy'], '-r', label= "Training")
plt.plot(history.history['val_accuracy'], '-b', label= "Validation")
plt.xlabel('Epoch #')
plt.ylabel('Accuracy')
plt.legend()
plt.show()

Here is the error. I am using the update version of keras and having the error. I am new to machine learning and any help will be appreciated

runfile('C:/Users/mwaqa/Desktop/Spyder/E7 Q1.py', wdir='C:/Users/mwaqa/Desktop/Spyder') Training data = (60000, 28, 28) (60000,) Test data = (10000, 28, 28) (10000,) Model: "sequential_29" _________________________________________________________________ Layer (type) Output Shape Param #
================================================================= conv2d_25 (Conv2D) (None, 26, 26, 16) 160
_________________________________________________________________ max_pooling2d_23 (MaxPooling (None, 13, 13, 16) 0
_________________________________________________________________ flatten_23 (Flatten) (None, 2704) 0
_________________________________________________________________ dense_49 (Dense) (None, 100) 270500
_________________________________________________________________ dense_50 (Dense) (None, 10) 1010
================================================================= Total params: 271,670 Trainable params: 271,670 Non-trainable params: 0 _________________________________________________________________ None Train on 54000 samples, validate on 6000 samples Epoch 1/20 Traceback (most recent call last):

  File "C:/Users/mwaqa/Desktop/Spyder/E7 Q1.py", line 57, in <module>
    model.fit(X_train, Y_train, batch_size = 64, epochs = 20, validation_split = 0.1, callbacks = [history])


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

Blockquote

Is all of the traceback required for this question? Can you shorten the error message? - Kyle Williamson
The traceback looks incomplete, please post the full traceback - Dr. Snoopy