sciai.architecture.Normalize

View Source On Gitee
class sciai.architecture.Normalize(lb, ub)[source]

Normalize inputs with given lower bound and upper bound.

Parameters
  • lb (Tensor) – Lower bound.

  • ub (Tensor) – Upper bound.

Inputs:
  • inputs (Tensor) - Input tensor to be normalized.

Outputs:

Tensor, The normalized tensor projected into [-1, 1].

Supported Platforms:

GPU CPU Ascend

Examples

>>> import mindspore as ms
>>> from mindspore import ops, nn
>>> from sciai.architecture.basic_block import Normalize
>>> x = ops.ones((3, 2), ms.float32)
>>> lb, ub = ops.Tensor([0, -0.5], ms.float32), ops.Tensor([2, 3.5], ms.float32)
>>> normalize = Normalize(lb, ub)
>>> res = normalize(x)
>>> print(res)
[[ 0.   -0.25]
 [ 0.   -0.25]
 [ 0.   -0.25]]