Week 4 Assignment 1, triplet loss

Hi there!

I stuck at

GRADED FUNCTION: triplet_loss

I think my codes are fine and I got the correct output at the end:

loss = tf.Tensor(527.2598, shape=(), dtype=float32)

But it told me that it is incorrect.

Can anyone point out where the problem could be?

Great thanks!


I spend some time to try to avoid the ‘AssertionError’, but couldn’t find a clue. Then I decided to continue the assignment.

I tried submitted the assignment after I finished the rest, and I got the full grade. So I guess it’s fine to have this error-reminding.

Just leave this topic here for those who also might encounter the same ‘bug’ (maybe its not).

It seems that your code for the triplet_loss() function does not work correctly for the data used in one of the unit tests.

Thanks! I went back and checked my code again, find the mistake: I typed ‘tf.reduce_max’ instead of ‘tf.reduce_sum’.

Surprisingly it passed the examination :laughing:

Interestingly, I made the same mistake. Must be the wording of the helper comment.