Face recognition: Result is correct, but The system produces error message

In face recognition, triplet loss implementation, my result is correct as I can see from the printout of loss value which is equal to: loss = tf.Tensor([[527.25977]], shape=(1, 1), dtype=float32)

But, for the following line, the system is emitting an error message, which I do not understand:
Here is the error message

Invalid reduction dimension (1 for input with 1 dimension(s) [Op:Sum]

for the line below:

pos_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, positive)), axis=1, keepdims=True)

Is it a bug?

Hi alhasan,

Note that the tensor your function returns contains a list, while it is supposed to contain a real number. How can you resolve this?