mindspore.dataset.vision.Normalize
- class mindspore.dataset.vision.Normalize(mean, std, is_hwc=True)[source]
Normalize the input image with respect to mean and standard deviation. This operator will normalize the input image with: output[channel] = (input[channel] - mean[channel]) / std[channel], where channel >= 1.
Note
This operation supports running on Ascend or GPU platforms by Offload.
- Parameters
mean (sequence) – List or tuple of mean values for each channel, with respect to channel order. The mean values must be in range [0.0, 255.0].
std (sequence) – List or tuple of standard deviations for each channel, with respect to channel order. The standard deviation values must be in range (0.0, 255.0].
is_hwc (bool, optional) – Whether the input image is HWC. True - HWC format, False - CHW format. Default: True.
- Raises
TypeError – If mean is not of type sequence.
TypeError – If std is not of type sequence.
TypeError – If is_hwc is not of type bool.
ValueError – If mean is not in range [0.0, 255.0].
ValueError – If std is not in range (0.0, 255.0].
RuntimeError – If given tensor format is not <H, W> or <…,H, W, C>.
- Supported Platforms:
CPU
Examples
>>> decode_op = vision.Decode() ## Decode output is expected to be HWC format >>> normalize_op = vision.Normalize(mean=[121.0, 115.0, 100.0], std=[70.0, 68.0, 71.0], is_hwc=True) >>> transforms_list = [decode_op, normalize_op] >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns=["image"])