Hello Everyone,
I am struggling with issue for following example in triplet loss
y_pred_perfect = ([[1., 1.]],[[1., 1.]], [[0., 0.,]])
loss = triplet_loss(y_true, y_pred_perfect, 3)
assert loss == 1., "Wrong value. Check that pos_dist = 0 and neg_dist = 2 in this example"
I am getting following values in my code
anchor = [[1.0, 1.0]]
positive = [[1.0, 1.0]]
negative = [[0.0, 0.0]]
pos_dist=tf.Tensor([0.], shape=(1,), dtype=float32)
neg_dist=tf.Tensor([1.9999999], shape=(1,), dtype=float32)
loss=tf.Tensor(1.0000001, shape=(), dtype=float32)
The issue is expected value for neg_dist=2
and loss=1
One way to solve the problem is change the type of tensor to float64 for anchor, positive and negative. But it is not mentioned anywhere in the assignment instructions. So I am not sure whether it is correct or not?
Any help is appreciated. Thanks in advance!