channel_normalize

dragon.channel_normalize(
  inputs,
  mean,
  std,
  axis=-1,
  dtype='float32',
  perm=None,
  **kwargs
)[source]

Normalize channels with mean and standard deviation.

The axis can be negative representing the last-k axis:

m = s = (1., 1., 1.)
x = dragon.constant([1, 2, 3])
print(dragon.channel_normalize(x, m, s, axis=0))   # [0., 1., 2.]
print(dragon.channel_normalize(x, m, s, axis=-1))  # Equivalent

If perm is 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.channel_normalize(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 axis to normalize.
  • 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.