Skip to contents

Applies Batch Normalization for each channel across a batch of data.

Input and Output Channels

One input channel called "input" and one output channel called "output". For an explanation see PipeOpTorch.

State

The state is the value calculated by the public method $shapes_out().

Credit

Part of this documentation have been copied or adapted from the documentation of torch.

Internals

Calls torch::nn_batch_norm2d(). The parameter num_features is inferred as the second dimension of the input shape.

Parameters

  • eps :: numeric(1)
    A value added to the denominator for numerical stability. Default: 1e-5.

  • momentum :: numeric(1)
    The value used for the running_mean and running_var computation. Can be set to NULL for cumulative moving average (i.e. simple average). Default: 0.1

  • affine :: logical(1)
    a boolean value that when set to TRUE, this module has learnable affine parameters. Default: TRUE

  • track_running_stats :: logical(1)
    a boolean value that when set to TRUE, this module tracks the running mean and variance, and when set to FALSE, this module does not track such statistics and always uses batch statistics in both training and eval modes. Default: TRUE

Super classes

mlr3pipelines::PipeOp -> mlr3torch::PipeOpTorch -> mlr3torch::PipeOpTorchBatchNorm -> PipeOpTorchBatchNorm2D

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

PipeOpTorchBatchNorm2D$new(id = "nn_batch_norm2d", param_vals = list())

Arguments

id

(character(1))
Identifier of the resulting object.

param_vals

(list())
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction.


Method clone()

The objects of this class are cloneable with this method.

Usage

PipeOpTorchBatchNorm2D$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Construct the PipeOp
pipeop = po("nn_batch_norm2d")
pipeop
#> PipeOp: <nn_batch_norm2d> (not trained)
#> values: <list()>
#> Input channels <name [train type, predict type]>:
#>   input [ModelDescriptor,Task]
#> Output channels <name [train type, predict type]>:
#>   output [ModelDescriptor,Task]
# The available parameters
pipeop$param_set
#> <ParamSet(4)>
#>                     id    class lower upper nlevels default  value
#>                 <char>   <char> <num> <num>   <num>  <list> <list>
#> 1:                 eps ParamDbl     0   Inf     Inf   1e-05 [NULL]
#> 2:            momentum ParamDbl     0   Inf     Inf     0.1 [NULL]
#> 3:              affine ParamLgl    NA    NA       2    TRUE [NULL]
#> 4: track_running_stats ParamLgl    NA    NA       2    TRUE [NULL]