tf.random.categorical(
logits,
num_samples,
dtype=None,
seed=None,
name=None
)
Defined in tensorflow/python/ops/random_ops.py.
Draws samples from a categorical distribution.
Example:
# samples has shape [1, 5], where each value is either 0 or 1 with equal
# probability.
samples = tf.random.categorical(tf.log([[10., 10.]]), 5)
Args:
logits: 2-D Tensor with shape[batch_size, num_classes]. Each slice[i, :]represents the unnormalized log-probabilities for all classes.num_samples: 0-D. Number of independent samples to draw for each row slice.dtype: integer type to use for the output. Defaults to int64.seed: A Python integer. Used to create a random seed for the distribution. Seetf.set_random_seedfor behavior.name: Optional name for the operation.
Returns:
The drawn samples of shape [batch_size, num_samples].