Exercise 3 Triplet Loss - cannot progress & conflicting instructions

Hi,
I am stuck. I have spent over a day on Exercise 3 - TripletLossFn. The instructions conflict, for example the detailed instruction say to use " triple_loss is the fastnp.mean of the sum of the two individual losses." while the code states " # add the two losses together and take the fastnp.sum of it ".

I do not understand this requirement with the masks. I find it confusing.

create a composition of two masks:

# the first mask to extract the diagonal elements, 
# the second mask to extract elements in the negative_zero_on_duplicate matrix that 
# are larger than the elements in the diagonal 

For the line " # the first mask to extract the diagonal elements, " → extract from what and in what shape ?

Again, for the second mask, what shape is it supposed to be. If I extract I reduce the shape. To extract elements that "are larger than the elements in the diagonal " - does this mean the the diagonal element in a row or the max of all diagonal elements or the diagonal i have already extracted ? How do you compare to elements ie the plural ?

The instructions are confusing and I am stuck. I have most of exercise 3 correct ( I hope ). I need some help with finalising this exercise please… so I can move on to the next exercise.

Thanks

Hi @Damieno

Check this post and compare your values. It might help you find the solution.

Good luck!

Hi, you have not clarified the instructions. Can you please explain and expand on

create a composition of two masks:

the first mask to extract the diagonal elements,

the second mask to extract elements in the negative_zero_on_duplicate matrix that

are larger than the elements in the diagonal

Also, is the final calculation fastnp.sum or .mean ? The instructions contradict each other.

Thanks

Ok, to clarify the instructions but without revealing the whole solution :):

image

This (mask) is a way to help you exclude the diagonal elements and elements that are larger than the diagonal elements. This is the heart :slight_smile: of Triplet Loss function.

It’s the former - fastnp.sum. The instructions will be corrected.

Cheers

Hi, thank you for the extra info and explanation. I have worked through the exercise variable by variable and successfully completed it.