Loss Value - Exercise 5 Week 3 Course 2

I seems to have something wrongly, the loss value for the model is not displaying

The first thing I’d suggest checking is to confirm that all the test code for the previous steps in the assignment worked as expected. In particular, did you get the expected result of

tf.Tensor(0.6931472, shape=(), dtype=float32)

for the train_one_step() test code?

If all that looks right, then you can try adding some print statements to narrow down where the problem is. Start by adding a print statement in your portion of the train() function, to print the value of loss right after you calculate it. It will probably be nan there too, so you’ll need to drill back into the function you called to calculate loss and place some strategic print statements there to help you find where things are going wrong.

Typical causes for nan (not a number) are dividing by zero, or taking the log or square root of a negative number, so be on the watch for something that might lead to this.

Good luck! Post back here with an update of how it went.

It’s solved, my error goes way back to normalizing the data.
I input img /= (img/255) instead of img /= 255

1 Like

Nice debugging, @Adaramola_Samson! :muscle: