TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tfa.losses.metric_learning.pairwise_distance

View source on GitHub

Computes the pairwise distance matrix with numerical stability.

tfa.losses.metric_learning.pairwise_distance(
    feature,
    squared=False
)

output[i, j] = || feature[i, :] - feature[j, :] ||_2

Args:

  • feature: 2-D Tensor of size [number of data, feature dimension].
  • squared: Boolean, whether or not to square the pairwise distances.

Returns:

  • pairwise_distances: 2-D Tensor of size [number of data, number of data].