channel_norm¶
dragon.nn.
channel_norm
(
inputs,
mean,
std,
axis=- 1,
dtype='float32',
perm=None,
**kwargs
)[source]¶Apply the normalization to each channel of input.
axis
can be negative:m = s = (1., 1., 1.) x = dragon.constant([1, 2, 3]) print(dragon.nn.channel_norm(x, m, s, axis=0)) # [0., 1., 2.] print(dragon.nn.channel_norm(x, m, s, axis=-1)) # Equivalent
If
perm
provided,axis
is selected from the output layout:m, s = (1., 2., 3.), (1., 1., 1.) x = dragon.constant([[1, 2, 3]]) # Provided 3 values to normalize the last axis # with length 1, only the first value will be taken print(dragon.nn.channel_norm(x, m, s, perm=(1, 0))) # [[0.], [1.], [2.]]
- Parameters:
- inputs (dragon.Tensor) – The input tensor.
- mean (Sequence[float], required) – The mean to subtract.
- std (Sequence[float], required) – The standard deviation to divide.
- axis (int, optional, default=-1) – The channel axis.
- dtype (str, optional, default='float32') – The output data type.
- perm (Sequence[Union[int, dragon.Tensor]], optional) – The output permutation.
- Returns:
dragon.Tensor – The output tensor.