Class ThreadUnsafeUnigramCandidateSampler
java.lang.Object
org.tensorflow.op.RawOp
org.tensorflow.op.random.ThreadUnsafeUnigramCandidateSampler
- All Implemented Interfaces:
Op
Generates labels for candidate sampling with a learned unigram distribution.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classOptional attributes forThreadUnsafeUnigramCandidateSampler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of this op, as known by TensorFlow core engine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(Scope scope, Operand<TInt64> trueClasses, Long numTrue, Long numSampled, Boolean unique, Long rangeMax, ThreadUnsafeUnigramCandidateSampler.Options... options) Factory method to create a class wrapping a new ThreadUnsafeUnigramCandidateSampler operation.Gets sampledCandidates.Gets sampledExpectedCount.Sets the seed option.Sets the seed2 option.Gets trueExpectedCount.
-
Field Details
-
OP_NAME
The name of this op, as known by TensorFlow core engine- See Also:
-
-
Constructor Details
-
ThreadUnsafeUnigramCandidateSampler
-
-
Method Details
-
create
@Endpoint(describeByClass=true) public static ThreadUnsafeUnigramCandidateSampler create(Scope scope, Operand<TInt64> trueClasses, Long numTrue, Long numSampled, Boolean unique, Long rangeMax, ThreadUnsafeUnigramCandidateSampler.Options... options) Factory method to create a class wrapping a new ThreadUnsafeUnigramCandidateSampler operation.- Parameters:
scope- current scopetrueClasses- A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.numTrue- Number of true labels per context.numSampled- Number of candidates to randomly sample.unique- 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.rangeMax- The sampler will sample integers from the interval [0, range_max).options- carries optional attribute values- Returns:
- a new instance of ThreadUnsafeUnigramCandidateSampler
-
seed
Sets the seed option.- Parameters:
seed- 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.- Returns:
- this Options instance.
-
seed2
Sets the seed2 option.- Parameters:
seed2- An second seed to avoid seed collision.- Returns:
- this Options instance.
-
sampledCandidates
-
trueExpectedCount
-
sampledExpectedCount
Gets sampledExpectedCount. A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.- Returns:
- sampledExpectedCount.
-