parameters: (self)
docstring: Create the value Tensor based on the value type, store as self._value.
docstring_summary: Create the value Tensor based on the value type, store as self._value.
docstring_tokens: Create the value Tensor based on the value type store as self . _value .
function: def _create_value(self):
      """Create the value Tensor based on the value type, store as self._value."""
  
      if isinstance(self._value_type, MeanValue):
        value_tensor = self._dist.mean()
      elif isinstance(self._value_type, SampleValue):
        value_tensor = self._dist.sample(self._value_type.n)
      elif isinstance(self._value_type, SampleAndReshapeValue):
        if self._value_type.n == 1:
          value_tensor = self._dist.sample()
        else:
          samples = self._dist.sample(self._value_type.n)
          samples_shape = array_ops.shape(samples)
          samples_static_shape = samples.get_shape()
          new_batch_size = samples_shape[0] * samples_shape[1]
          value_tensor = array_ops.reshape(
              samples, array_ops.concat(0, ([new_batch_size], samples_shape[2:])))
          if samples_static_shape.ndims is not None:
            # Update the static shape for shape inference purposes
            shape_list = samples_static_shape.as_list()
            new_shape = tensor_shape.vector(
                shape_list[0] * shape_list[1]
                if shape_list[0] is not None and shape_list[1] is not None
                else None)
            new_shape = new_shape.concatenate(samples_static_shape[2:])
            value_tensor.set_shape(new_shape)
      else:
        raise TypeError(
            "Unrecognized Distribution Value Type: %s", self._value_type)
  
      if self._value_type.stop_gradient:
        # stop_gradient is being enforced by the value type
        return array_ops.stop_gradient(value_tensor)
  
      if isinstance(self._value_type, MeanValue):
        return value_tensor  # Using pathwise-derivative for this one.
      if self._dist.is_continuous and self._dist.is_reparameterized:
        return value_tensor  # Using pathwise-derivative for this one.
      else:
        # Will have to perform some variant of score function
        # estimation.  Call stop_gradient on the sampler just in case we
        # may accidentally leak some gradient from it.
        return array_ops.stop_gradient(value_tensor)
function_tokens: def _create_value ( self ) : if isinstance ( self . _value_type , MeanValue ) : value_tensor = self . _dist . mean ( ) elif isinstance ( self . _value_type , SampleValue ) : value_tensor = self . _dist . sample ( self . _value_type . n ) elif isinstance ( self . _value_type , SampleAndReshapeValue ) : if self . _value_type . n == 1 : value_tensor = self . _dist . sample ( ) else : samples = self . _dist . sample ( self . _value_type . n ) samples_shape = array_ops . shape ( samples ) samples_static_shape = samples . get_shape ( ) new_batch_size = samples_shape [ 0 ] * samples_shape [ 1 ] value_tensor = array_ops . reshape ( samples , array_ops . concat ( 0 , ( [ new_batch_size ] , samples_shape [ 2 : ] ) ) ) if samples_static_shape . ndims is not None : # Update the static shape for shape inference purposes shape_list = samples_static_shape . as_list ( ) new_shape = tensor_shape . vector ( shape_list [ 0 ] * shape_list [ 1 ] if shape_list [ 0 ] is not None and shape_list [ 1 ] is not None else None ) new_shape = new_shape . concatenate ( samples_static_shape [ 2 : ] ) value_tensor . set_shape ( new_shape ) else : raise TypeError ( "Unrecognized Distribution Value Type: %s" , self . _value_type ) if self . _value_type . stop_gradient : # stop_gradient is being enforced by the value type return array_ops . stop_gradient ( value_tensor ) if isinstance ( self . _value_type , MeanValue ) : return value_tensor # Using pathwise-derivative for this one. if self . _dist . is_continuous and self . _dist . is_reparameterized : return value_tensor # Using pathwise-derivative for this one. else : # Will have to perform some variant of score function # estimation.  Call stop_gradient on the sampler just in case we # may accidentally leak some gradient from it. return array_ops . stop_gradient ( value_tensor )