Learn R Programming

ggmlR (version 0.8.4)

nn_build_batch_norm: Build batch_norm forward pass

Description

Normalizes per channel over the BATCH axis -- and, for conv-shaped inputs, over every spatial position as well -- the defining property of batch normalization. During training the statistics come from the current batch; at inference time the stored running estimates are used instead, so a prediction depends only on the sample itself and not on which other samples share its batch. Mirrors ag_batch_norm() in the autograd API.

Usage

nn_build_batch_norm(ctx, input_tensor, layer, training = TRUE)

Value

A ggml_tensor with batch-normalized, scaled and shifted values.

Arguments

training

Logical; use batch statistics (TRUE) or running estimates (FALSE).

Details

For a flat [features, batch] input the batch axis is ne[1]. Reductions in ggml run along ne[0], hence the transposes: they move the batch axis into reduction position and back. Conv-shaped inputs need a different rearrangement and are handled by nn_bn_normalize_conv().