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: ‘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,)