AttributeError: 'myCallback' object has no attribute 'set_model'

For this assignment, I get this error:

AttributeError                            Traceback (most recent call last)
<ipython-input-41-1733272e84a3> in <module>
----> 1 hist = train_mnist(x_train, y_train)

<ipython-input-40-5e7da0d37834> in train_mnist(x_train, y_train)
     24     # Fit the model for 10 epochs adding the callbacks
     25     # and save the training history
---> 26     history =, y_train, epochs=10, callbacks=[callbacks])
     28     ### END CODE HERE

/opt/conda/lib/python3.8/site-packages/keras/utils/ in error_handler(*args, **kwargs)
     65     except Exception as e:  # pylint: disable=broad-except
     66       filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67       raise e.with_traceback(filtered_tb) from None
     68     finally:
     69       del filtered_tb

/opt/conda/lib/python3.8/site-packages/keras/ in set_model(self, model)
    283       model.history = self._history
    284     for callback in self.callbacks:
--> 285       callback.set_model(model)
    287   def _call_batch_hook(self, mode, hook, batch, logs=None):

AttributeError: 'myCallback' object has no attribute 'set_model'

How do I fix it?

the callbacks object here callbacks=[callbacks] might not actually be a valid callback object. Following the following format might clear your issue. Let me know if it does.
Please take a look what myCallback is.

my_callbacks = [
    tf.keras.callbacks.ModelCheckpoint(filepath='<checkpoint path>'),
], epochs=10, callbacks=my_callbacks)

EarlyStopping, ModelCheckpoint,TensorBoard are some valid callback objects.

Can you please refer to this and let me know if you are inheriting from the correct class of tf.keras.callback.Callback ?