Normalizer#
Domain:
ai.onnx.mlSince version: 1
Normalize the input. There are three normalization modes, which have the corresponding formulas, defined using element-wise infix operators ‘/’ and ‘^’ and tensor-wide functions ‘max’ and ‘sum’:
Max: Y = X / max(X) L1: Y = X / sum(X) L2: Y = sqrt(X^2 / sum(X^2)} In all modes, if the divisor is zero, Y == X.
For batches, that is, [N,C] tensors, normalization is done along the C axis. In other words, each row of the batch is normalized independently.
Inputs
X (T): Data to be encoded, a tensor of shape [N,C] or [C]
Outputs
Y (tensor(float)): Encoded output data
Type Constraints
T: The input must be a tensor of a numeric type. Allowed types: tensor(double), tensor(float), tensor(int32), tensor(int64).
Examples#
test_cc_normalizer_l1_int64
Node:
ai.onnx.ml.Normalizer(x) -> (y)
Attributes:
norm = "L1"
Inputs:
x: shape=(4,), dtype=int64
[ 1, -1, 2, -2]
Outputs:
y: shape=(4,), dtype=float32
[ 0.16666667, -0.16666667, 0.33333334, -0.33333334]
test_cc_normalizer_l2_float
Node:
ai.onnx.ml.Normalizer(x) -> (y)
Attributes:
norm = "L2"
Inputs:
x: shape=(2, 3), dtype=float32
[[1., 2., 2.],
[0., 3., 4.]]
Outputs:
y: shape=(2, 3), dtype=float32
[[0.33333334, 0.6666667 , 0.6666667 ],
[0. , 0.6 , 0.8 ]]
test_cc_normalizer_max_double
Node:
ai.onnx.ml.Normalizer(x) -> (y)
Attributes:
norm = "MAX"
Inputs:
x: shape=(2, 3), dtype=float64
[[ 1., -3., 2.],
[ 0., 0., 0.]]
Outputs:
y: shape=(2, 3), dtype=float32
[[ 0.5, -1.5, 1. ],
[ 0. , 0. , 0. ]]