def __init__(
      self,
      logits=None,
      probs=None,
      dtype=tf.int32,
      validate_args=False,
      allow_nan_stats=True,
      name="Categorical"):
    """Initialize Categorical distributions using class log-probabilities.

    Args:
      logits: An N-D `Tensor`, `N >= 1`, representing the log probabilities
        of a set of Categorical distributions. The first `N - 1` dimensions
        index into a batch of independent distributions and the last dimension
        represents a vector of logits for each class. Only one of `logits` or
        `probs` should be passed in.
      probs: An N-D `Tensor`, `N >= 1`, representing the probabilities
        of a set of Categorical distributions. The first `N - 1` dimensions
        index into a batch of independent distributions and the last dimension
        represents a vector of probabilities for each class. Only one of
        `logits` or `probs` should be passed in.
      dtype: The type of the event samples (default: int32).
      validate_args: Python `bool`, default `False`. When `True` distribution
        parameters are checked for validity despite possibly degrading runtime
        performance. When `False` invalid inputs may silently render incorrect
        outputs.
      allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
        (e.g., mean, mode, variance) use the value "`NaN`" to indicate the
        result is undefined. When `False`, an exception is raised if one or
        more of the statistic's batch members are undefined.
      name: Python `str` name prefixed to Ops created by this class.
    """
    parameters = dict(locals())
    with tf.name_scope(name) as name:
      self._logits, self._probs = distribution_util.get_logits_and_probs(
          logits=logits,
          probs=probs,
          validate_args=validate_args,
          multidimensional=True,
          name=name)

      if validate_args:
        self._logits = distribution_util.embed_check_categorical_event_shape(
            self._logits)

      logits_shape_static = tensorshape_util.with_rank_at_least(
          self._logits.shape, 1)
      if tensorshape_util.rank(logits_shape_static) is not None:
        self._batch_rank = tf.convert_to_tensor(
            value=tensorshape_util.rank(logits_shape_static) - 1,
            dtype=tf.int32,
            name="batch_rank")
      else:
        with tf.name_scope("batch_rank"):
          self._batch_rank = tf.rank(self._logits) - 1

      logits_shape = tf.shape(input=self._logits, name="logits_shape")
      num_categories = tf.compat.dimension_value(logits_shape_static[-1])
      if num_categories is not None:
        self._num_categories = tf.convert_to_tensor(
            value=num_categories, dtype=tf.int32, name="num_categories")
      else:
        with tf.name_scope("num_categories"):
          self._num_categories = logits_shape[self._batch_rank]

      if tensorshape_util.is_fully_defined(logits_shape_static[:-1]):
        self._batch_shape_val = tf.constant(
            logits_shape_static[:-1].as_list(),
            dtype=tf.int32,
            name="batch_shape")
      else:
        with tf.name_scope("batch_shape"):
          self._batch_shape_val = logits_shape[:-1]
    super(Categorical, self).__init__(
        dtype=dtype,
        reparameterization_type=reparameterization.NOT_REPARAMETERIZED,
        validate_args=validate_args,
        allow_nan_stats=allow_nan_stats,
        parameters=parameters,
        graph_parents=[self._logits,
                       self._probs],
        name=name)
def __init__ ( self , logits = None , probs = None , dtype = tf . int32 , validate_args = False , allow_nan_stats = True , name = "Categorical" ) : parameters = dict ( locals ( ) ) with tf . name_scope ( name ) as name : self . _logits , self . _probs = distribution_util . get_logits_and_probs ( logits = logits , probs = probs , validate_args = validate_args , multidimensional = True , name = name ) if validate_args : self . _logits = distribution_util . embed_check_categorical_event_shape ( self . _logits ) logits_shape_static = tensorshape_util . with_rank_at_least ( self . _logits . shape , 1 ) if tensorshape_util . rank ( logits_shape_static ) is not None : self . _batch_rank = tf . convert_to_tensor ( value = tensorshape_util . rank ( logits_shape_static ) - 1 , dtype = tf . int32 , name = "batch_rank" ) else : with tf . name_scope ( "batch_rank" ) : self . _batch_rank = tf . rank ( self . _logits ) - 1 logits_shape = tf . shape ( input = self . _logits , name = "logits_shape" ) num_categories = tf . compat . dimension_value ( logits_shape_static [ - 1 ] ) if num_categories is not None : self . _num_categories = tf . convert_to_tensor ( value = num_categories , dtype = tf . int32 , name = "num_categories" ) else : with tf . name_scope ( "num_categories" ) : self . _num_categories = logits_shape [ self . _batch_rank ] if tensorshape_util . is_fully_defined ( logits_shape_static [ : - 1 ] ) : self . _batch_shape_val = tf . constant ( logits_shape_static [ : - 1 ] . as_list ( ) , dtype = tf . int32 , name = "batch_shape" ) else : with tf . name_scope ( "batch_shape" ) : self . _batch_shape_val = logits_shape [ : - 1 ] super ( Categorical , self ) . __init__ ( dtype = dtype , reparameterization_type = reparameterization . NOT_REPARAMETERIZED , validate_args = validate_args , allow_nan_stats = allow_nan_stats , parameters = parameters , graph_parents = [ self . _logits , self . _probs ] , name = name )
Initialize Categorical distributions using class log-probabilities.

    Args:
      logits: An N-D `Tensor`, `N >= 1`, representing the log probabilities
        of a set of Categorical distributions. The first `N - 1` dimensions
        index into a batch of independent distributions and the last dimension
        represents a vector of logits for each class. Only one of `logits` or
        `probs` should be passed in.
      probs: An N-D `Tensor`, `N >= 1`, representing the probabilities
        of a set of Categorical distributions. The first `N - 1` dimensions
        index into a batch of independent distributions and the last dimension
        represents a vector of probabilities for each class. Only one of
        `logits` or `probs` should be passed in.
      dtype: The type of the event samples (default: int32).
      validate_args: Python `bool`, default `False`. When `True` distribution
        parameters are checked for validity despite possibly degrading runtime
        performance. When `False` invalid inputs may silently render incorrect
        outputs.
      allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
        (e.g., mean, mode, variance) use the value "`NaN`" to indicate the
        result is undefined. When `False`, an exception is raised if one or
        more of the statistic's batch members are undefined.
      name: Python `str` name prefixed to Ops created by this class.