tf.raw_ops.LearnedUnigramCandidateSampler
Stay organized with collections Save and categorize content based on your preferences.
Generates labels for candidate sampling with a learned unigram distribution.
tf.raw_ops.LearnedUnigramCandidateSampler(
true_classes,
num_true,
num_sampled,
unique,
range_max,
seed=0,
seed2=0,
name=None
)
See explanations of candidate sampling and the data formats at go/candidate-sampling.
For each batch, this op picks a single set of sampled candidate labels.
The advantages of sampling candidates per-batch are simplicity and the possibility of efficient dense matrix multiplication. The disadvantage is that the sampled candidates must be chosen independently of the context and of the true labels.
Args |
---|
true_classes | A Tensor of type int64 . A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label. |
num_true | An int that is >= 1 . Number of true labels per context. |
num_sampled | An int that is >= 1 . Number of candidates to randomly sample. |
unique | A bool . If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities. |
range_max | An int that is >= 1 . The sampler will sample integers from the interval [0, range_max). |
seed | An optional int . Defaults to 0 . If either seed or seed2 are set to be non-zero, the random number generator is seeded by the given seed. Otherwise, it is seeded by a random seed. |
seed2 | An optional int . Defaults to 0 . An second seed to avoid seed collision. |
name | A name for the operation (optional). |
Returns |
---|
A tuple of Tensor objects (sampled_candidates, true_expected_count, sampled_expected_count). |
sampled_candidates | A Tensor of type int64 . |
true_expected_count | A Tensor of type float32 . |
sampled_expected_count | A Tensor of type float32 . |
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. Some content is licensed under the numpy license.
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."],[],[]]