mindspore.nn.probability.bijector.Invert

class mindspore.nn.probability.bijector.Invert(bijector, name='')[source]

Invert Bijector. Compute the inverse function of the input bijector.

Parameters
  • bijector (Bijector) – Base Bijector.

  • name (str) – The name of the Bijector. Default: “”. When name is set to “”, it is actually ‘Invert’ + bijector.name.

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> import mindspore
>>> import mindspore.nn as nn
>>> import mindspore.nn.probability.bijector as msb
>>> from mindspore import Tensor
>>> class Net(nn.Cell):
...     def __init__(self):
...         super(Net, self).__init__()
...         self.origin = msb.ScalarAffine(scale=2.0, shift=1.0)
...         self.invert = msb.Invert(self.origin)
...
...     def construct(self, x_):
...         return self.invert.forward(x_)
>>> forward = Net()
>>> x = np.array([2.0, 3.0, 4.0, 5.0]).astype(np.float32)
>>> ans = forward(Tensor(x, dtype=mindspore.float32))
>>> print(ans.shape)
(4,)
property bijector

Return base bijector.

forward(x)[source]

Perform the forward transformation of the inverse bijector, namely the inverse transformation of the underlying bijector.

Parameters

x (Tensor) – the value of the input random variable.

Output:

Tensor, the value of the transformed random variable.

forward_log_jacobian(x)[source]

Logarithm of the derivative of the forward transformation of the inverse bijector, namely logarithm of the derivative of the inverse transformation of the underlying bijector.

Parameters

x (Tensor) – the value of the input random variable.

Output:

Tensor, logarithm of the derivative of the forward transformation of the inverse bijector.

inverse(y)[source]

Perform the inverse transformation of the inverse bijector, namely the forward transformation of the underlying bijector.

Parameters

y (Tensor) – the value of the transformed random variable.

Output:

Tensor, the value of the input random variable.

inverse_log_jacobian(y)[source]

Logarithm of the derivative of the inverse transformation of the inverse bijector, namely logarithm of the derivative of the forward transformation of the underlying bijector.

Parameters

y (Tensor) – the value of the transformed random variable.

Output:

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