mindspore.nn.probability.bijector.Bijector

class mindspore.nn.probability.bijector.Bijector(is_constant_jacobian=False, is_injective=True, name=None, dtype=None, param=None)[source]

Bijecotr class. A bijector perform a mapping from one distribution to the other via some function. If \(X\) is a random variable following the original distribution, and \(g(x)\) is the mapping function, then \(Y = g(X)\) is the random variable following the transformed distribution.

Parameters
  • is_constant_jacobian (bool) – Whether the Bijector has constant derivative. Default: False .

  • is_injective (bool) – Whether the Bijector is a one-to-one mapping. Default: True .

  • name (str) – The name of the Bijector. Default: None .

  • dtype (mindspore.dtype) – The type of the distributions that the Bijector can operate on. Default: None .

  • param (dict) – The parameters used to initialize the Bijector. Default: None .

Note

dtype of bijector represents the type of the distributions that the bijector could operate on. When dtype is None, there is no enforcement on the type of input value except that the input value has to be float type. During initialization, when dtype is None, there is no enforcement on the dtype of the parameters. All parameters should have the same float type, otherwise a TypeError will be raised. Specifically, the parameter type will follow the dtype of the input value, i.e. parameters of the bijector will be casted into the same type as input value when dtype is None. When dtype is specified, it is forcing the parameters and input value to be the same dtype as dtype. When the type of parameters or the type of the input value is not the same as dtype, a TypeError will be raised. Only subtype of mindspore.float_type can be used to specify bijector's dtype.

Supported Platforms:

Ascend GPU

cast_param_by_value(value, para)[source]

Cast the parameter(s) of the bijector to be the same type of input_value.

Parameters
  • value (Tensor) – input value.

  • para (Tensor) – parameter(s) of the bijector.

Returns

Tensor, the value of parameters after casting.

construct(name, *args, **kwargs)[source]

Override construct in Cell.

Note

Names of supported functions include: 'forward', 'inverse', 'forward_log_jacobian', and 'inverse_log_jacobian'.

Parameters
  • name (str) – The name of the function.

  • *args (list) – the list of positional arguments forwarded to subclasses.

  • **kwargs (dict) – the dictionary of keyword arguments forwarded to subclasses.

Returns

Tensor, the result of the function corresponding to name.

forward(value, *args, **kwargs)[source]

Forward transformation: transform the input value to another distribution.

Parameters
  • value (Tensor) – the value of the input variables.

  • *args (list) – the list of positional arguments forwarded to subclasses.

  • **kwargs (dict) – the dictionary of keyword arguments forwarded to subclasses.

Returns

Tensor, the value of the transformed random variable.

forward_log_jacobian(value, *args, **kwargs)[source]

Logarithm of the derivative of the forward transformation.

Parameters
  • value (Tensor) – the value of the input variables.

  • *args (list) – the list of positional arguments forwarded to subclasses.

  • **kwargs (dict) – the dictionary of keyword arguments forwarded to subclasses.

Returns

Tensor, the value of logarithm of the derivative of the forward transformation.

inverse(value, *args, **kwargs)[source]

Inverse transformation: transform the input value back to the original distribution.

Parameters
  • value (Tensor) – the value of the transformed variables.

  • *args (list) – the list of positional arguments forwarded to subclasses.

  • **kwargs (dict) – the dictionary of keyword arguments forwarded to subclasses.

Returns

Tensor, the value of the input random variable.

inverse_log_jacobian(value, *args, **kwargs)[source]

Logarithm of the derivative of the inverse transformation.

Parameters
  • value (Tensor) – the value of the transformed variables.

  • *args (list) – the list of positional arguments forwarded to subclasses.

  • **kwargs (dict) – the dictionary of keyword arguments forwarded to subclasses.

Returns

Tensor, the value of logarithm of the derivative of the inverse transformation.