Week 4 Face Recognition UNQ_C1Unit test with wrong answer

Hi there,

I am encountering a problem with the final unit test of the triplet loss exercise. All other unit tests passed but because this one fails I am getting a 66/100 grader output and cannot pass the assignment.

The final unit test goes like this:
y_pred_perfect = ([[1., 1.], [2., 0.]], [[0., 3.], [1., 1.]], [[1., 0.], [0., 1.,]])
loss = triplet_loss(y_true, y_pred_perfect, 1)
assert loss == 5, “Wrong value. Check your implementation”

My function implementation yields loss = 3.0.
When I do the hand calculation of this simple example, I am also getting 3 as an answer so I don’t understand how I should get 5. Is there an error with the unit test?


That’s weird. For that test case, even manually doing it I do get a value of 5. I don’t think there is an error with the unit test. Considering you do seem to be passing the earlier test cases, there might be some weird error in your logic. Could you dm me your code for this function?

A note for others who face the same problem later on. Check if you’ve followed the last step of taking the max with 0 and summing over the examples in the right order.

1 Like