Face _Recognition

What is the error here?

loss = tf.Tensor(527.2598, shape=(), dtype=float32)

TypeError Traceback (most recent call last)
in
11
12 y_pred_perfect = ([1., 1.], [1., 1.], [1., 1.,])
—> 13 loss = triplet_loss(y_true, y_pred_perfect, 5)
14 assert loss == 5, “Wrong value. Did you add the alpha to basic_loss?”
15 y_pred_perfect = ([1., 1.],[1., 1.], [0., 0.,])

in triplet_loss(y_true, y_pred, alpha)
22 #(≈ 4 lines)
23 # Step 1: Compute the (encoding) distance between the anchor and the positive
—> 24 pos_dist = tf.reduce_sum(tf.square(anchor - positive), axis = -1)
25 # Step 2: Compute the (encoding) distance between the anchor and the negative
26 neg_dist = tf.reduce_sum(tf.square(anchor - negative), axis = -1)

TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’

1 Like

The error suggests that subtracting two lists “(anchor - positive)” is not allowed in python.
Try the “tf.subtract()” function instead.

1 Like