Skip to content

StandardizePreprocessor

Bases: DataPreprocessor

Data preprocessor that applies standardization

Examples:

Assume the data is a 3-channel image of data type float32.

You can scale the data to have a mean of 0 and a standard deviation of 1 by standardizing the data. In this example, the mean and standard deviation values from the ImageNet dataset are used.

>>> standardize_preprocessor = StandardizePreprocessor(
...     mean_values=[.485, .456, .406],
...     std_values=[.229, .224, .225],
... )
>>> preprocessed_data = standardize_preprocessor(data)
PARAMETER DESCRIPTION
mean_values

mean values of the data (per channel)

TYPE: list[float]

std_values

standard deviation values of the data (per channel)

TYPE: list[float]

from_config classmethod

Creates a standardize preprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: StandardizePreprocessorConfig

RETURNS DESCRIPTION
StandardizePreprocessor

standardize preprocessor

__call__

Preprocesses the data by applying standardization.

PARAMETER DESCRIPTION
data

data

TYPE: npt.NDArray

RETURNS DESCRIPTION
npt.NDArray[np.float32]

preprocessed data


StandardizePreprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of StandardizePreprocessor

ATTRIBUTE DESCRIPTION
mean_values

mean values of the data (per channel)

TYPE: list[float]

std_values

standard deviation values of the data (per channel)

TYPE: list[float]