I’m having a little difficulty getting the expected output for the triplet_loss function.
I’m using tf functions for every operation. So this handles the test cases when tensors and lists are used without error exception.
So I tried to find the issue by printing the values at each step.
pos_dist
tf.Tensor([3122.1926 3377.6548 3365.9343], shape=(3,), dtype=float32)
neg_dist
tf.Tensor([3905.9553 2850.595 3434.0498], shape=(3,), dtype=float32)
basic_loss before tf.reduce.sum
tf.Tensor([-783.5627 527.2598 -67.91548], shape=(3,), dtype=float32)
basic_loss after tf.reduce.sum
tf.Tensor(-324.21832, shape=(), dtype=float32)
loss (of course it results in zero because loss was negative in the previous step)
loss = tf.Tensor(0.0, shape=(), dtype=float32)
I can see the expected output of 527.2598 in the basic_loss before tf.reduce.sum, but I don’t understand what I’m doing wrong.