Hello, I am struggling with excersise 02, in week3 in course 3 (Natural Language Processing with Sequence Models). I think I’ve done everything right, but I still get Triplet loss as 4.907, not 0.70. How can I debug each element (each tensor), to know if I am on the right path? Or, could I paste my code (which is probably wrong in some place, thus does not include the full solution), to get a review?

Best,
Eleonora Kulberkyte

hi @Eleonora_Kulberkyte

go through below threads

The hint is a bit misleading, even I was stuck because of the same, arvyzukai NLP mentor guided me through
So based on the instruction previous shared, axis should be 1
For the mask exclude positives, your code is correct.
Next thing, check if the score codes is recalled as (v2, v1, transpose_b=true), note v2 is placed before v1
Hi @roses_r_red
Your code requires correction for triplet_loss1 and triplet_loss2
While calculating the A and B
A = subtract positive from margin and add closest_negative
B = subtract positive from margin and add mean_negative
You have used correctly the codes but because you have missed tuppling in these codes caused these error.
Remember the instructions mentions first to subtract (margin-positive) and then add closest negative for A and mean_negative for B
Also while recalling triplet …
The below link is another way to check if your each step value matches so you know where you need to correct

Hi @Jawad
You can heck your calculations (by printing intermediate values) against these and see where they start to differ:
[image]
Cheers
let me know if still issue persist

Regards
DP

Hi Deepti,

This was super good: C3W3Assignment: Exercise 02 TripletLossFn() - #2 by arvyzukai . Thanks for your help!

Best,
Eleonora

1 Like

that was the same thread that help me debug my codes when I was doing the assignment first time.

Keep Learning!!!