tfrs.layers.loss.HardNegativeMining
Stay organized with collections
Save and categorize content based on your preferences.
Transforms logits and labels to return hard negatives.
tfrs.layers.loss.HardNegativeMining(
num_hard_negatives: int
) -> None
Args |
num_hard_negatives
|
How many hard negatives to return.
|
Methods
call
View source
call(
logits: tf.Tensor, labels: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
Filters logits and labels with per-query hard negative mining.
The result will include logits and labels for num_hard_negatives
negatives as well as the positive candidate.
Args |
logits
|
[batch_size, number_of_candidates] tensor of logits.
|
labels
|
[batch_size, number_of_candidates] one-hot tensor of labels.
|
Returns |
logits
|
[batch_size, num_hard_negatives + 1] tensor of logits.
|
labels
|
[batch_size, num_hard_negatives + 1] one-hot tensor of labels.
|
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 2024-04-26 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 2024-04-26 UTC."],[],[]]