class_docstr: Gaussian distribution, for continuous actions (specification key: `gaussian`).
  
  Args:
      stddev_mode ("predicted" | "global"): Whether to predict the standard deviation via a linear
          transformation of the state embedding, or to parametrize the standard deviation by a
          separate set of trainable weights
          (<span style="color:#00C000"><b>default</b></span>: "predicted").
      bounded_transform ("clipping" | "tanh"): Transformation to adjust sampled actions in case of
          bounded action space, "tanh" transforms distribution (e.g. log probability computation)
          accordingly whereas "clipping" does not
          (<span style="color:#00C000"><b>default</b></span>: tanh).
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      action_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      input_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Gaussian","distribution",",","for","continuous","actions","(","specification","key",":","`","gaussian","`",")",".","Args",":","stddev_mode","(","``","predicted","''","|","``","global","''",")",":","Whether","to","predict","the","standard","deviation","via","a","linear","transformation","of","the","state","embedding",",","or","to","parametrize","the","standard","deviation","by","a","separate","set","of","trainable","weights","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","``","predicted","''",")",".","bounded_transform","(","``","clipping","''","|","``","tanh","''",")",":","Transformation","to","adjust","sampled","actions","in","case","of","bounded","action","space",",","``","tanh","''","transforms","distribution","(","e.g",".","log","probability","computation",")","accordingly","whereas","``","clipping","''","does","not","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","tanh",")",".","name","(","string",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","action_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","input_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def parametrize(self, *, x, conditions):
      epsilon = tf_util.constant(value=util.epsilon, dtype="float")
      log_epsilon = tf_util.constant(
          value=np.log(util.epsilon), dtype="float"
      )
  
      # Mean
      mean = self.mean.apply(x=x)
      if self.input_spec.rank == 1:
          shape = (-1,) + self.action_spec.shape
          mean = tf.reshape(tensor=mean, shape=shape)
  
      # Softplus standard deviation
      if self.stddev_mode == "global":
          multiples = (tf.shape(input=x)[0],) + tuple(
              1 for _ in range(self.action_spec.rank)
          )
          softplus_stddev = tf.tile(
              input=self.stddev, multiples=multiples
          )
      else:
          softplus_stddev = self.stddev.apply(x=x)
          if self.input_spec.rank == 1:
              softplus_stddev = tf.reshape(
                  tensor=softplus_stddev, shape=shape
              )
  
      # # Shift softplus_stddev to reduce zero value to 0.25 (TODO: 0.25 random choice)
      # if self.action_spec.min_value is not None and self.action_spec.max_value is not None:
      #     softplus_stddev += tf_util.constant(value=np.log(0.25), dtype='float')
  
      # Clip softplus_stddev for numerical stability (epsilon < 1.0, hence negative)
      softplus_stddev = tf.clip_by_value(
          t=softplus_stddev,
          clip_value_min=log_epsilon,
          clip_value_max=-log_epsilon,
      )
  
      # Softplus transformation (based on https://arxiv.org/abs/2007.06059)
      softplus_shift = tf_util.constant(value=0.2, dtype="float")
      log_two = tf_util.constant(value=np.log(2.0), dtype="float")
      stddev = (
          tf.nn.softplus(features=softplus_stddev) + softplus_shift
      ) / (log_two + softplus_shift)
  
      # Divide stddev to reduce zero value to 0.25 (TODO: 0.25 random choice)
      if (
          self.action_spec.min_value is not None
          and self.action_spec.max_value is not None
      ):
          stddev *= tf_util.constant(value=0.25, dtype="float")
  
      # Log stddev
      log_stddev = tf.math.log(x=(stddev + epsilon))
  
      return TensorDict(mean=mean, stddev=stddev, log_stddev=log_stddev)
  
file_path: tensorforce/tensorforce/core/distributions/gaussian.py
imports: import numpy
  import tensorflow
  from tensorforce import TensorforceError, util
  from tensorforce.core import layer_modules, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util
  from tensorforce.core.distributions import Distribution
label_desc: Use image node_id 4 for calling the Gaussian obj's underlying member method code with example usage: obj.parametrize() and returns: TensorDict