mindelec.architecture.InputScaleNet

class mindelec.architecture.InputScaleNet(input_scale, input_center=None)[source]

Scale the input value to specified region.

Parameters
  • input_scale (list) – The scale factor of input x/y/t.

  • input_center (Union[list, None]) – Center position of coordinate translation. Default: None.

Inputs:
  • input (Tensor) - Tensor of shape \((*, channels)\).

Outputs:

Tensor of shape \((*, channels)\).

Supported Platforms:

Ascend

Raises
  • TypeError – If input_scale is not a list.

  • TypeError – If input_center is not a list or None.

Examples

>>> import numpy as np
>>> from mindelec.architecture import InputScaleNet
>>> from mindspore import Tensor
>>> inputs = np.random.uniform(size=(16, 3)) + 3.0
>>> inputs = Tensor(inputs.astype(np.float32))
>>> input_scale = [1.0, 2.0, 4.0]
>>> input_center = [3.5, 3.5, 3.5]
>>> net = InputScaleNet(input_scale, input_center)
>>> output = net(inputs).asnumpy()
>>> assert np.all(output[:, 0] <= 0.5) and np.all(output[:, 0] >= -0.5)
>>> assert np.all(output[:, 1] <= 1.0) and np.all(output[:, 0] >= -1.0)
>>> assert np.all(output[:, 2] <= 2.0) and np.all(output[:, 0] >= -2.0)