Week 3 programing assignment, Exercise 6 ( compute_total_loss) - wrong value

Hi,

What am I supposed to do if I get a wrong value, but I have no idea why? The rules say I am not allowed to put my code here, so how do I get help?

Some more details:

  • I transposed logits and labels
  • I fed these into tf.keras.losses.categorical_crossentropy, with from_logits=True
  • The output of that is then summed by tf.reduce_sum

So, I believe the outcome should be correct, but I get the following assertion error:
“AssertionError: Test does not match. Did you get the reduce sum of your loss functions?”
If I understand correctly, the expected outcome is 1.62057414 (0.50722074 + 1.1133534), but my outcome is 40.436035 (23.754297 + 16.68174).

Thanks!
Tal

All that you describe sounds correct. Are you sure that you are actually executing that code? You have to click “Shift-Enter” on the function cell after you change it. If you change it and then run the test cell again, it runs the old code, right?

One more thing to check is that you have the order of the arguments correct. It’s labels as the first argument (transposed of course) and then logits as the second argument to the loss function.

The other way to make sure everything is consistent is to do:

  1. Kernel → Restart and Clear Output
  2. Save
  3. Cell → Run All

And note that if we can’t figure out your problem this way, there are private ways to share code. First try what I just suggested and then let us know if that changes things or not.

Thanks! I had the order of the arguments wrong (logits and then labels). That solved it :slight_smile:

That’s good news! Glad you found the solution.