简体   繁体   中英

Mean Euclidean distance in Tensorflow

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?

给定两个张量AB每个张量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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM