tf.contrib.losses.metric_learning.triplet_semihard_loss
Stay organized with collections
Save and categorize content based on your preferences.
Computes the triplet loss with semi-hard negative mining.
tf.contrib.losses.metric_learning.triplet_semihard_loss(
labels, embeddings, margin=1.0
)
The loss encourages the positive distances (between a pair of embeddings with
the same labels) to be smaller than the minimum negative distance among
which are at least greater than the positive distance plus the margin constant
(called semi-hard negative) in the mini-batch. If no such negative exists,
uses the largest negative distance instead.
See: https://arxiv.org/abs/1503.03832
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
be l2 normalized.
|
margin
|
Float, margin term in the loss definition.
|
Returns |
triplet_loss
|
tf.float32 scalar.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[]]