myCallback funtion is not working


The training is not getting cancelled.

Hi @Shantanu7

Could you please check if the callback function is configured properly and if it is being applied in the training process as intended?

Make sure to use self.model.stop_training = True in your callback function.

yes, i fully checked my code, the same code i wrote in my notebook but it’s still do all epoch training.

Have you tried restarting the kernel?

Hello @Shantanu7

Check if your logs code is correctly written. It should be
logs=None
if logs.get(‘accuracy’) is not None and logs.get(‘accuracy’) > 0.99:

Let me know, if issue still persist or resolves.

Regards
DP

yes, but it’s did’nt work

yes its correctly written

Hey bro pls solve this problem, i am not able to completing my first course

Honestly if you see the below message, it is perfectly fine with the warning msg, as it states that you would get that message before 9 epoch then your callback worked perfectly fine. It never said training would stop.

Did you submit your assignment?

yes, the gradder give me 75% marks.

Can you share a screenshot of grader submission, why you scored 75%?

That does provide information on why there is an issue

Can you also investigate which TF version is deployed? Looks like there are some 2.x levels where this was broken, at least for some callbacks…

1 Like

hey, did you find the answer ?

@Shantanu7 you can check the TF version yourself by adding this code to a new cell in your environment (ie colab or Jupyter notebook) and then running the cell. Comment out or remove before submitting for grade…better safe than sorry

import tensorflow as tf
tf.__version__

If you share the results it could help rule out one possible source of problems. Note, I think it is not the issue, since others aren’t reporting same symptoms, but this is an easy test to do. Let us know?

Hello @Shantanu7

As mentioned by @ai_curious, I hope you mentioned or added the below code line after the print statement while recalling myCallback

Stop training once the above condition is met
self.model.stop_training = True

if yes and still encountering this issue then please send me your notebook, via personal DM. Let me have a look at your assignment. Click on my name and then message.

Regards
DP

1 Like

Thank you @ai_curious, it does seem he has mentioned that condition and yet having issue, probably there might be indentation related error for this condition when he recalled. Will check and update.

Regards
DP