megengine.functional.nn.batch_norm¶
- batch_norm(inp, running_mean=None, running_var=None, weight=None, bias=None, *, training=False, momentum=0.9, eps=1e-05, inplace=True)[source]¶
Applies batch normalization to the input.
Refer to
BatchNorm2d
andBatchNorm1d
for more information.- Parameters
inp (
Tensor
) – input tensor.running_mean (
Optional
[Tensor
]) – tensor to store running mean.running_var (
Optional
[Tensor
]) – tensor to store running variance.weight (
Optional
[Tensor
]) – scaling tensor in the learnable affine parameters. See \(\gamma\) inBatchNorm2d
.bias (
Optional
[Tensor
]) – bias tensor in the learnable affine parameters. See \(\beta\) inBatchNorm2d
.training (
bool
) – a boolean value to indicate whether batch norm is performed in training mode. Default: Falsemomentum (
float
) – value used for therunning_mean
andrunning_var
computation. Default: 0.9eps (
float
) – a value added to the denominator for numerical stability. Default: 1e-5inplace (
bool
) – whether to updaterunning_mean
andrunning_var
inplace or return new tensors. Default: Truecompute_mode – When set to ‘default’, no special requirements will be placed on the precision of intermediate results. When set to ‘float32’, float32 would be used for accumulator and intermediate result, but only effective when input and output are of float16 dtype.
param_dim – a value indicating in which format the parameters are. Default: ‘dim_1c11’, which means NCHW format. And ‘dim_111c’ means NHWC format.