|TensorFlow 1 version||View source on GitHub|
Samples a set of classes using a log-uniform (Zipfian) base distribution.
Compat aliases for migration
See Migration guide for more details.
tf.random.log_uniform_candidate_sampler( true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None )
Used in the notebooks
|Used in the tutorials|
This operation randomly samples a tensor of sampled classes
sampled_candidates) from the range of integers
The elements of
sampled_candidates are drawn without replacement
unique=True) or with replacement (if
the base distribution.
The base distribution for this operation is an approximately log-uniform or Zipfian distribution:
P(class) = (log(class + 2) - log(class + 1)) / log(range_max + 1)
This sampler is useful when the target classes approximately follow such a distribution - for example, if the classes represent words in a lexicon sorted in decreasing order of frequency. If your classes are not ordered by decreasing frequency, do not use this op.
In addition, this operation returns tensors
sampled_expected_count representing the number of times each
of the target classes (
true_classes) and the sampled
sampled_candidates) is expected to occur in an average
tensor of sampled classes. These values correspond to
defined in this
unique=True, then these are post-rejection probabilities and we
compute them approximately.