C3W3: TripletLossFn in Assignment

Hi. I was unable to pass one test in TripletLoss function. I checked this post (C3W3Assignment: Exercise 02 TripletLossFn()) and compared my values against the values provided there. I was getting an incorrect value in the very beginning. For me, the variable ‘scores’ looked like this:

[[ 1. -0.95350769]
[ 0.95350769 -1. ]]

However, according to the post, that value should be:

[[ 1. 0.95350769]
[ -0.95350769 -1. ]]

I realized that if I did: tf.linalg.matmul(v2, v1, transpose_b = True) instead of tf.linalg.matmul(v1, v2, transpose_b = True), I was able to pass the test.

Why should we use tf.linalg.matmul(v2, v1, transpose_b = True) instead of tf.linalg.matmul(v1, v2, tranpose_b = True).

Thank you!

1 Like

Well, in the instructions it tells you its V2xV1(transposed). Generally speaking when doing matrix multiplication (which essentially is happening with this code), A*B is not equal to BxA!

2 Likes

Oh, you’re right! Thank you very much!

1 Like