Why cant i implement my callback function

[Code removed by mentor]
Hopping someone please help me with this

Hello @Pinnamaneni_Ganesh ,

Welcome to the community!!

Posting codes publicly is against our community guidelines.

Send me your notebook via dm such that I can check where it went wrong. By clicking on the profile picture, you will see an option to message. There you can attach your notebook. Then we can discuss the issues here.

With regards,
Nilosree Sengupta

Hello @Pinnamaneni_Ganesh ,

I can see you have marked my above response as the solution, which is not a solution indeed. Kindly send me your notebook via dm such that I can check where it went wrong and help you towards reaching the actual solution.

With regards,
Nilosree Sengupta

Hello @Pinnamaneni_Ganesh ,

Saw your code snippet. There are several issues :

  1. I see you have imported tf, keras and numpy in the callback cell. Don’t import anything.
  1. You don’t need to define x_train and y_train here.
  2. Your logic of checking accuracy is wrong
  3. Print statement is wrong too.
    Check this hint :

Write an MNIST classifier that trains to 99% accuracy and stops once this threshold is achieved. In the lecture you saw how this was done for the loss but here you will be using accuracy instead.

Some notes:

When it reaches 99% or greater it should print out the string “Reached 99% accuracy so cancelling training!” and stop training.

  1. Don’t write the model creating and training part here. I see you have taken 1000 epochs?! that too in the cell of callback .

Those are in next cell. And Number of epoch should be 10, not 1k.

It’s written in hint:

Create and train your model

Now that you have defined your callback it is time to complete the train_mnist function below.

You must set your model to train for 10 epochs and the callback should fire before the 9th epoch for you to pass this assignment.

Hope this helps.

note: read the hints.
You can discuss this freely here. I asked DM just to send notebook/snippet.

With regards,
Nilosree Sengupta