def __call__(self): """Get the distribution object from the backend""" if get_backend() == 'pytorch': import torch.distributions as tod return tod.cauchy.Cauchy(self.loc, self.scale) else: from tensorflow_probability import distributions as tfd return tfd.Cauchy(self.loc, self.scale)
def _create_dist(self): scale_diag = tf.nn.softplus(self._scale_variable) if self._softplus_scale \ else self._scale_variable scale = distribution_util.make_diag_scale(loc=self._loc_variable, scale_diag=scale_diag, validate_args=False, assert_positive=False) batch_shape, event_shape = distribution_util.shapes_from_loc_and_scale( self._loc_variable, scale) return tfp.TransformedDistribution( distribution=tfp.Cauchy(loc=tf.zeros([], dtype=scale.dtype), scale=tf.ones([], dtype=scale.dtype)), bijector=bijectors.AffineLinearOperator(shift=self._loc_variable, scale=scale), batch_shape=batch_shape, event_shape=event_shape, name="MultivariateCauchyDiag" + ("SoftplusScale" if self._softplus_scale else ""))
def _init_distribution(conditions, **kwargs): loc, scale = conditions["loc"], conditions["scale"] return tfd.Cauchy(loc=loc, scale=scale, **kwargs)
def _base_dist(self, alpha: TensorLike, beta: TensorLike, *args, **kwargs): return tfd.Cauchy(loc=alpha, scale=beta, **kwargs)
def _create_dist(self): if self._softplus_scale: return tfd.Cauchy(self._loc_variable, tf.nn.softplus(self._scale_variable)) return tfd.Cauchy(self._loc_variable, self._scale_variable)