示例#1
0
  def __init__(self,
               df,
               validate_args=False,
               allow_nan_stats=True,
               name='Chi'):
    """Construct Chi distributions with parameter `df`.

    Args:
      df: Floating point tensor, the degrees of freedom of the
        distribution(s). `df` must contain only positive values.
      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.
        Default value: `'Chi'`.
    """
    parameters = dict(locals())
    with tf.name_scope(name) as name:
      dtype = dtype_util.common_dtype([df], dtype_hint=tf.float32)
      self._df = tensor_util.convert_nonref_to_tensor(
          df, name='df', dtype=dtype)
      super(Chi, self).__init__(
          distribution=chi2.Chi2(df=self._df,
                                 validate_args=validate_args,
                                 allow_nan_stats=allow_nan_stats),
          bijector=invert_bijector.Invert(
              square_bijector.Square(validate_args=validate_args)),
          validate_args=validate_args,
          parameters=parameters,
          name=name)
示例#2
0
 def _default_event_space_bijector(self):
   # TODO(b/145620027) Finalize choice of bijector.
   return chain_bijector.Chain([
       invert_bijector.Invert(
           square_bijector.Square(validate_args=self.validate_args),
           validate_args=self.validate_args),
       softmax_centered_bijector.SoftmaxCentered(
           validate_args=self.validate_args)
   ], validate_args=self.validate_args)
示例#3
0
  def __init__(self,
               df,
               validate_args=False,
               allow_nan_stats=True,
               name="Chi"):
    """Construct Chi distributions with parameter `df`.

    Args:
      df: Floating point tensor, the degrees of freedom of the
        distribution(s). `df` must contain only positive values.
      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.
        Default value: `'Chi'`.
    """
    with tf.compat.v1.name_scope(name, values=[df]) as name:
      df = tf.convert_to_tensor(
          value=df,
          name="df",
          dtype=dtype_util.common_dtype([df], preferred_dtype=tf.float32))
      validation_assertions = [tf.compat.v1.assert_positive(df)
                              ] if validate_args else []
      with tf.control_dependencies(validation_assertions):
        self._df = tf.identity(df, name="df")

      super(Chi, self).__init__(
          distribution=chi2.Chi2(df=self._df,
                                 validate_args=validate_args,
                                 allow_nan_stats=allow_nan_stats,
                                 name=name),
          bijector=invert_bijector.Invert(square_bijector.Square()))