mindspore.nn.probability.bijector.Invert
- class mindspore.nn.probability.bijector.Invert(bijector, name='')[source]
Invert Bijector. Compute the inverse function of the input bijector. If the function of the forward mapping, namely the input of bijector below, is \(Y = g(X)\), then the function of corresponding inverse mapping Bijector is \(Y = h(X) = g^{-1}(X)\).
- Parameters:
- Supported Platforms:
AscendGPUCPU
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().__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]
Compute the inverse mapping of underlying Bijector, namely \(Y = h(X) = g^{-1}(X)\) .
- Parameters
x (Tensor) - the value of output after mapping by the underlying bijector.
- Returns
Tensor, the inverse mapping of underlying Bijector.
- forward_log_jacobian(x)[source]
Compute the log value of the inverse mapping of underlying Bijector \(\log dg^{-1}(x) / dx\).
- Parameters
x (Tensor) - the value of output after mapping by the underlying bijector.
- Returns
Tensor, the log value of the inverse mapping of underlying Bijector.
- inverse(y)[source]
Compute the forward mapping of underlying Bijector, namely \(Y = g(X)\).
- Parameters
y (Tensor) - the value to compute by the underlying bijector.
- Returns
Tensor, the forward mapping of underlying Bijector.
- inverse_log_jacobian(y)[source]
Compute the log value of the forward mapping of underlying Bijector, namely \(Y = \log dg(x) / dx\).
- Parameters
y (Tensor) - the value to compute by the underlying bijector.
- Returns
Tensor, the log value of forward mapping of underlying Bijector.
- 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.