Skip to contents

Normalizes the channels by subtracting mean and dividing by std. The channels are the third-to-last dimension, e.g. C for images of shape (N, C, H, W) or videos of shape (N, T, C, H, W), as in torchvision::transform_normalize, which this is the same as for these inputs. For inputs with fewer dimensions, e.g. (N, C) or (N, C, L), the channels are the second dimension. Inputs that are not floating point, e.g. images stored as integers, are converted to the default floating point type (torch_get_default_dtype()) first. The preprocessing is applied to the whole batch.

Being a trafo_ operator, its stages parameter starts out as "both", so the transformation is applied both while training and when predicting. Set stages = "train" to restrict it to training. See PipeOpTaskPreprocTorch for the stages parameter and this naming convention.

Format

R6Class inheriting from PipeOpTaskPreprocTorch.

Construction

po("trafo_normalize")

Parameters

IdTypeDefaultLevels
meanuntyped-
stduntyped-
stagescharacter-train, predict, both
affect_columnsuntypedselector_all()