C3W3_Assignment NLP

Week : 3, Course 3 from the NLP specialization
Link_to_item:

Description: Hi, Have an issue with the triplet loss where my answer is wrong,
so the logic goes that we are implementing one shot learning similar to the facial recognition assignment in a different specialization, except we dont need to extract the loss 1 and loss 2 from different calculations and instead we use multiply all the Pairs together and then pick how much was it correct in picking its duplicate and then we look for the worse performing false positive from the same calculation aka matrix multiplication, at least this is what I am understanding.
my code logic is as follows:
scores= matmul(v1,v2,transpose_b=True)
positive = diag_part(scores)
then we subtract scored with the diagonal positive matrix to create negative zero duplicate

then using that calculate the mean_negative by producing the reduce of negative_zero_on_duplicate,axis=1)/(batch_size - 1)

up until here I am not sure if my word is correct or not and I do feel like my math logic is wrong here simply because I don’t fully comprehend the usage of matrix operations in one shot learning and hardness, I can see how efficient it is but simply can’t wrap my head around it, if someone can correct my logic for coding and/or explain the math operations it would be much appreciated.

Hi @HASHEM_JABER

below comment has two comments related to triple loss, check if any of the two threads solves your issue in where you might have gone wrong.

Also as a general rule, sharing a screenshot of error or your outout to expected output is more better idea, although your explanation is great.

let me know if you still have any issue.

Regards
DP

Roger that Ms Prasad,
Thank you for the assistance, sadly and fortunately it helped me correct a section of my code but not all, been stuck for a good while on it but will try to take a fresh look on it, maybe I am misunderstanding something on it

you can share screenshot of your error or the different output you are getting, so mentors can understand where you might be going wrong.

I would suggest to go through all the pinned comments, there are many post related to triple loss, when you search with specific course and and week, you will find them.