tensorflow::ops::AllCandidateSampler

#include <candidate_sampling_ops.h>

Generates labels for candidate sampling with a learned unigram distribution.

Summary

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:

  • scope: A Scope object
  • true_classes: 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: Number of true labels per context.
  • num_sampled: Number of candidates to produce.
  • 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.

Optional attributes (see Attrs):

  • 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.
  • seed2: An second seed to avoid seed collision.

Returns:

  • Output sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • Output true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • Output sampled_expected_count: 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.

Constructors and Destructors

AllCandidateSampler(const ::tensorflow::Scope & scope, ::tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique)
AllCandidateSampler(const ::tensorflow::Scope & scope, ::tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, const AllCandidateSampler::Attrs & attrs)

Public attributes

operation
sampled_candidates
sampled_expected_count
true_expected_count

Public static functions

Seed(int64 x)
Seed2(int64 x)

Structs

tensorflow::ops::AllCandidateSampler::Attrs

Optional attribute setters for AllCandidateSampler.

Public attributes

operation

Operation operation

sampled_candidates

::tensorflow::Output sampled_candidates

sampled_expected_count

::tensorflow::Output sampled_expected_count

true_expected_count

::tensorflow::Output true_expected_count

Public functions

AllCandidateSampler

 AllCandidateSampler(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input true_classes,
  int64 num_true,
  int64 num_sampled,
  bool unique
)

AllCandidateSampler

 AllCandidateSampler(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input true_classes,
  int64 num_true,
  int64 num_sampled,
  bool unique,
  const AllCandidateSampler::Attrs & attrs
)

Public static functions

Seed

Attrs Seed(
  int64 x
)

Seed2

Attrs Seed2(
  int64 x
)