mindflow.cell.InputScale
- class mindflow.cell.InputScale(input_scale, input_center=None)[source]
Scale the input value to specified region based on \((x_i - input\_center)*input\_scale\)
- Parameters
- Inputs:
input (Tensor) - Tensor of shape \((*, channels)\).
- Outputs:
Tensor of shape \((*, channels)\).
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> from mindflow.cell import InputScale >>> 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 = InputScale(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)