W3cubDocs

/TensorFlow Python

tf.contrib.losses.metric_learning.lifted_struct_loss

tf.contrib.losses.metric_learning.lifted_struct_loss(
    labels,
    embeddings,
    margin=1.0
)

Defined in tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py.

Computes the lifted structured loss.

The loss encourages the positive distances (between a pair of embeddings with the same labels) to be smaller than any negative distances (between a pair of embeddings with different labels) in the mini-batch in a way that is differentiable with respect to the embedding vectors. See: https://arxiv.org/abs/1511.06452.

Args:

  • labels: 1-D tf.int32 Tensor with shape [batch_size] of multiclass integer labels.
  • embeddings: 2-D float Tensor of embedding vectors. Embeddings should not be l2 normalized.
  • margin: Float, margin term in the loss definition.

Returns:

  • lifted_loss: tf.float32 scalar.

© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/losses/metric_learning/lifted_struct_loss