Normalize#

class torchaug.transforms.Normalize(mean, std, cast_dtype=None, inplace=False, value_check=False)[source]#

Normalize a tensor image with mean and standard deviation. Given mean: (mean[1],...,mean[n]) and std: (std[1],..,std[n]) for n channels, this transform will normalize each channel of the input torch.Tensor i.e.,

output[channel] = (input[channel] - mean[channel]) / std[channel]

Parameters:
  • mean (Union[Sequence[float], float]) – Sequence of means for each channel.

  • std (Union[Sequence[float], float]) – Sequence of standard deviations for each channel.

  • cast_dtype (Optional[dtype], optional) – If not None, scale and cast input to dtype. Expected to be a float dtype.

    Default: None

  • inplace (bool, optional) – Bool to make this operation in-place.

    Default: False

  • value_check (bool, optional) – Bool to perform tensor value check. Might cause slow down on some devices because of synchronization.

    Default: False

forward(tensor)[source]#

Normalize tensor.

Parameters:

tensor (Tensor) – The tensor to normalize.

Return type:

Tensor

Returns:

Normalized tensor.