Deep Learning Course 4 week

I am facing problem while executing Exercise 1- Triplet loss,
I am facing error while executing the specific cell .

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

AssertionError Traceback (most recent call last)
14 y_pred_perfect = ([[1., 1.]], [[1., 1.]], [[1., 1.,]])
15 loss = triplet_loss(y_true, y_pred_perfect, 5)
—> 16 assert loss == 5, “Wrong value. Did you add the alpha to basic_loss?”
17 y_pred_perfect = ([[1., 1.]],[[1., 1.]], [[0., 0.,]])
18 loss = triplet_loss(y_true, y_pred_perfect, 3)

AssertionError: Wrong value. Did you add the alpha to basic_loss?

Anybody’s help is appreciated.
Also I’m attaching the screenshot of error below for reference.

It asks you, Did you add the alpha to basic_loss? Did you add it? The problem is because you probably havent done that!

That’s just one possible error. Note that the value being generated is way higher than the expected value and alpha is positive, right? So that’s not likely to be the issue here.

Probably the most popular error on this computation is taking the max of the sums instead of taking the sum of the maxes in the last step of the calculation. That gives a much different result. :scream_cat:

Update: although I just tried making that mistake and it doesn’t generate the same answer shown in the OP here. More thought required. But the basic procedure is to step through the calculation and make sure you understand all the math notation there. In particular the little “plus subscript” there is pretty subtle. But they give very complete instructions: make sure not to “save time” by skipping a careful reading of all the instructions.


Yes sir, I have added the alpha to the basic los.

Hello @paulinpaloalto,

I’ve already taken the sum of maxes,
Would definitely work on your suggestion of going Through the calculations from the start and see what happens.

Sahreen Haider.