I have two tensors of sequences of size [batch_size, seq_length, 2]. I want to compute mean Euclidean distance between tensors. What is the elegant way to do this?
给定两个张量A
和B
每个张量A
形状为[batch_size, seq_length, 2]
,您可以使用tf.norm
计算欧几里得距离(L2 范数):
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.