Type Categorical
Namespace tensorflow.distributions
Parent Distribution
Interfaces ICategorical
Categorical distribution. The Categorical distribution is parameterized by either probabilities or
log-probabilities of a set of `K` classes. It is defined over the integers
`{0, 1,..., K}`. The Categorical distribution is closely related to the `OneHotCategorical` and
`Multinomial` distributions. The Categorical distribution can be intuited as
generating samples according to `argmax{ OneHotCategorical(probs) }` itself
being identical to `argmax{ Multinomial(probs, total_count=1) }`. #### Mathematical Details The probability mass function (pmf) is, ```none
pmf(k; pi) = prod_j pi_j**[k == j]
``` #### Pitfalls The number of classes, `K`, must not exceed:
- the largest integer representable by `self.dtype`, i.e.,
`2**(mantissa_bits+1)` (IEEE 754),
- the maximum `Tensor` index, i.e., `2**31-1`. In other words,
Note: This condition is validated only when `self.validate_args = True`. #### Examples Creates a 3-class distribution with the 2nd class being most likely.
Creates a 3-class distribution with the 2nd class being most likely.
Parameterized by [logits](https://en.wikipedia.org/wiki/Logit) rather than
probabilities.
Creates a 3-class distribution with the 3rd class being most likely.
The distribution functions can be evaluated on counts.
Show Example
K <= min(2**31-1, { tf.float16: 2**11, tf.float32: 2**24, tf.float64: 2**53 }[param.dtype])
Properties
- allow_nan_stats
- allow_nan_stats_dyn
- batch_shape
- batch_shape_dyn
- dtype
- dtype_dyn
- event_shape
- event_shape_dyn
- event_size
- event_size_dyn
- logits
- logits_dyn
- name
- name_dyn
- parameters
- parameters_dyn
- probs
- probs_dyn
- PythonObject
- reparameterization_type
- reparameterization_type_dyn
- validate_args
- validate_args_dyn
Public properties
object allow_nan_stats get;
object allow_nan_stats_dyn get;
TensorShape batch_shape get;
object batch_shape_dyn get;
object dtype get;
object dtype_dyn get;
TensorShape event_shape get;
object event_shape_dyn get;
Tensor event_size get;
Scalar `int32` tensor: the number of classes.
object event_size_dyn get;
Scalar `int32` tensor: the number of classes.
object logits get;
Vector of coordinatewise logits.
object logits_dyn get;
Vector of coordinatewise logits.
string name get;
object name_dyn get;
IDictionary<object, object> parameters get;
object parameters_dyn get;
Tensor probs get;
Vector of coordinatewise probabilities.
object probs_dyn get;
Vector of coordinatewise probabilities.