normalize#

torchaug.transforms.functional.normalize(tensor, mean, std, cast_dtype=None, inplace=False, value_check=False)[source]#

Normalize a tensor image with mean and standard deviation.

Note

If tensor is not float, user has to set cast_dtype to a float torch.dtype, otherwise it will raise an error. The function will cast and scale the tensor and return a normalized float tensor.

See Normalize for more details.

Parameters:
  • tensor (Tensor) – Tensor image of size (C, H, W) or (B, C, H, W) to be normalized.

  • mean (list[float] | Tensor) – Sequence of means for each channel.

  • std (list[float] | Tensor) – 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 inplace.

    Default: False

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

    Default: False

Return type:

Tensor

Returns:

Normalized float Tensor image.