Mean Euclidean distance in Tensorflow
Given the two tensors A
& B
each with shape [batch_size, seq_length, 2]
, you can compute the Euclidean distance (L2 norm) using tf.norm
:
l2_norm = tf.norm(A-B, ord='euclidean')
You can also use tf.math.reduce_euclidean_norm:
tf.math.reduce_euclidean_norm(
input_tensor, axis=None, keepdims=False, name=None
)
see the documentation here.