class_docstr: GumbelSoftmax distribution with temperature and logits.
  
  The implementation is almost identical to tfp.distributions.
  relaxed_onehot_categorical.RelaxedOneHotCategorical except for the following:
  
  1. Add mode() function to return mode of the underlying categorical
     distribution (There is no mode() defined in RelaxedOneHotCategorical)
  2. Add a convert_to_integer() function to convert the sample from non-integer
     to integer. Note that the sample function returns one_hot format of the
     discrete action that is different from regular distributions.
  3. log_prob() of RelaxedOneHotCategorical will return INF when the input is
     at boundary. In this implementation, we add a small epsilon to avoid
     getting NAN. In addition, when the input is discrete, we calculate log_prob
     using the underlying categorical distribution.
class_docstr_tok: ["GumbelSoftmax","distribution","with","temperature","and","logits",".","The","implementation","is","almost","identical","to","tfp.distributions",".","relaxed_onehot_categorical.RelaxedOneHotCategorical","except","for","the","following",":","1",".","Add","mode","(",")","function","to","return","mode","of","the","underlying","categorical","distribution","(","There","is","no","mode","(",")","defined","in","RelaxedOneHotCategorical",")","2",".","Add","a","convert_to_integer","(",")","function","to","convert","the","sample","from","non-integer","to","integer",".","Note","that","the","sample","function","returns","one_hot","format","of","the","discrete","action","that","is","different","from","regular","distributions",".","3.","log_prob","(",")","of","RelaxedOneHotCategorical","will","return","INF","when","the","input","is","at","boundary",".","In","this","implementation",",","we","add","a","small","epsilon","to","avoid","getting","NAN",".","In","addition",",","when","the","input","is","discrete",",","we","calculate","log_prob","using","the","underlying","categorical","distribution","."]
docstr: Initialize GumbelSoftmax using class log-probabilities.
  
  Args:
    temperature: A `Tensor`, representing the temperature of one or more
      distributions. The temperature values must be positive, and the shape
      must broadcast against `(logits or probs)[..., 0]`.
    logits: An N-D `Tensor`, `N >= 1`, representing the log probabilities of
      one or many 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 one or
      many 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.
docstr_tok: ["Initialize","GumbelSoftmax","using","class","log-probabilities",".","Args",":","temperature",":","A","`","Tensor","`",",","representing","the","temperature","of","one","or","more","distributions",".","The","temperature","values","must","be","positive",",","and","the","shape","must","broadcast","against","`","(","logits","or","probs",")","[","...",",","0","]","`",".","logits",":","An","N-D","`","Tensor","`",",","`","N",">","=","1","`",",","representing","the","log","probabilities","of","one","or","many","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","one","or","many","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","."]
code: def __init__(
      self,
      temperature,
      logits=None,
      probs=None,
      dtype=tf.int32,
      validate_args=False,
      allow_nan_stats=True,
      name="GumbelSoftmax",
  ):
      """Initialize GumbelSoftmax using class log-probabilities.
  
      Args:
        temperature: A `Tensor`, representing the temperature of one or more
          distributions. The temperature values must be positive, and the shape
          must broadcast against `(logits or probs)[..., 0]`.
        logits: An N-D `Tensor`, `N >= 1`, representing the log probabilities of
          one or many 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 one or
          many 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.
      """
      super(GumbelSoftmax, self).__init__(
          temperature=temperature,
          logits=logits,
          probs=probs,
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
      )
  
      self._output_dtype = dtype
  
file_path: agents/tf_agents/distributions/gumbel_softmax.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v2
  import tensorflow_probability
label_desc: Use image node_id 1 to create a new GumbelSoftmax object from inherited base classes: tfp.distributions.relaxed_onehot_categorical with example: obj = GumbelSoftmax(temperature, logits, probs, dtype, validate_args, allow_nan_stats, name)