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:
Ascend
GPU
CPU
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]
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.