),"The order of normalized_axis is incorrect, should be {}, but got {}. Please specify the values of axis in the correct order in normalized_axis".format(
sorted(normalized_axis),normalized_axis
)
assert(
normalized_axis[-1]<inp.ndim,
),"the maximum axis in normalized_axis is greater than inp_shape.ndim"
assertlen(set(normalized_axis))==len(
normalized_axis
),"there are duplicate axis in list normalized_axis"
),"there are duplicate axis in normalized_axis"
_reshape=[]
_rereshape=[]
...
...
@@ -1200,7 +1200,7 @@ def general_norm(
)!=(len(normalized_axis)-1)
if_need_reshape:
get_logger().warning(
"normalized_axis is discontinuous, and performance may be poor."
"normalized_axis is discontinuous, and performance may be poor"
The standard-deviation is calculated via the biased estimator.
Args:
normalized_axis(int, list or tuple): the axis of input needs to be normalized. Default: -1
normalized_shape(int, list or tuple): the shape of input needs to be normalized, normalized_shape must be specified when affine is true. When affine=true, we will directly use this shape to initialize weight/bias. Please ensure that the order is correct. Default: None
normalized_axis(int, list or tuple): the axis of input needs to be normalized, one-to-one correspondence between normalized_axis and normalized_shape. Default: -1
eps: a value added to the denominator for numerical stability. Default: 1e-5
affine: this module has learnable affine parameters (weight, bias) when affine is set to be True.
>>> m = M.GeneralNorm((3, 4), (1, -1)) # Please be careful.
>>> out = m(inp)
>>> out.numpy().shape
(2, 3, 4, 4)
>>> m = M.GeneralNorm((2, 4, 3), (0, 2, 1)) # Incorrect initialization, the order of normalized_axis is incorrect, should be adjusted to m = M.GeneralNorm((2, 3, 4), (0, 1, 2)).
>>> m = M.GeneralNorm((2, 4, 3), (0, -2, 1)) # Incorrect initialization, the order of normalized_axis is incorrect, should be adjusted to m = M.GeneralNorm((2, 3, 4), (0, 1, -2)).
>>> m = M.GeneralNorm((3, 4), (3, -1)) # Incorrect initialization, because axis=-1 and axis=3 are the same axis, namely axis=3.
),"The order of normalized_axis is incorrect, should be {}, but got {}. Please specify the values of axis in the correct order in normalized_axis".format(