{'fraction_non_alphanumeric': 0.033448531226857564, 'fraction_numerical': 0.02316300501933679, 'mean_word_length': 4.605857933579336, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Extended Batch Normalization

Batch normalization (BN) has become a standard technique for training the modern deep networks. However, its effectiveness diminishes when the batch size becomes smaller, since the batch statistics estimation becomes inaccurate. That hinders batch normalization's usage for 1) training larger model which requires small batches constrained by memory consumption, 2) training on mobile or embedded devices of which the memory resource is limited. In this paper, we propose a simple but effective method, called extended batch normalization (EBN). For NCHW format feature maps, extended batch normalization computes the mean along the (N, H, W) dimensions, as the same as batch normalization, to maintain the advantage of batch normalization. To alleviate the problem caused by small batch size, extended batch normalization computes the standard deviation along the (N, C, H, W) dimensions, thus enlarges the number of samples from which the standard deviation is computed. We compare extended batch normalization with batch normalization and group normalization on the datasets of MNIST, CIFAR-10/100, STL-10, and ImageNet, respectively. The experiments show that extended batch normalization alleviates the problem of batch normalization with small batch size while achieving close performances to batch normalization with large batch size.


Introduction
Deep neural networks have received great success in many areas. Batch normalization (BN) has become a standard technique for training the modern deep networks. It normalizes the features by the mean and the standard deviation computed within a batch of samples. When training with batch normalization, examples are seen in conjunction with each other in the minibatch. The model looks at multiple training examples in integration, rather than in isolation. The coordination between examples helps the learning process. Moreover, the random selection of examples in the minibatch brings the sampling noises, that provides similar regularization benefits as Dropout [26].
However, its effectiveness diminishes when the batch size becomes smaller, since the noises are too much and make inaccurate batch statistics estimation.
That hinders batch normalizations usage for 1) training larger (deeper and wider) models which requires small batches constrained by memory consumption. 2) training on mobile or embedded devices of which the memory resource is limited. Training model on edge devices has received more and more attention. For example, federated learning, a hot topic in machine learning, aims at training a model across multiple decentralized edge devices or servers to address privacy and security issues. The heterogeneous environments require a robust training algorithm with large or small batch size.
Several normalization methods have been proposed to address the problem caused by small batch size, e.g. normalization propagation [1], batch renormalization [8], kalman normalization [28]. The complexity limits their usage in the community. Group normalization [29] is simple and effective method to handle the training with small batch size. However, there is a extra hyper parameter G (the number of group) to be tuned in group normalization. When G is large, the number of channels per group decreases. Then the estimation of the mean and the standard deviation (std) may be inaccurate. As G equals to the number of channel of the layer, group normalization becomes instance normalization [27]. When G is small, the number of channels in the same group increases, but this makes the channels more correlative with each other. When G equals to 1, group normalization becomes layer normalization [2].
In this paper, we propose a simple but effective method, called extended batch normalization (EBN). The key difference between extended batch normalization and other normalization methods is that extended batch normalization compute the mean and the standard deviation from different set of pixels. For NCHW format feature, let N refer to batch dimension, C refer to channel dimension, H and W refer to the spatial height and width dimensions. To maintain the advantage of batch normalization, extended batch normalization computes the mean along the (N,H,W) dimensions just as the same as batch normalization. To alleviate the problem caused by small batch size, extended batch normalization computes the standard deviation along the (N, C, H, W) dimensions, thus enlarges the number of pixel samples from which the standard deviation is computed.
At inference time for extended batch normalization, the mean and the standard deviation are pre-computed from the training set by moving average as the same as batch normalization. There is no need to compute the mean and the standard deviation at inference time comparing to group normalization. Moreover, since the mean and the standard deviation are pre-computed and fixed at inference time, the normalization can be fused into convolution operation. That is very helpful to speed up the inference especially on the mobile or embedded devices.
We compare extended batch normalization with batch normalization and group normalization on the datasets of MNIST, CIFAR-10/100, STL-10, and ImageNet, respectively. The experiments show that extended batch normalization alleviates the problem of batch normalization with small batch size while achieving close performances to batch normalization with large batch size.

Related Work
Batch normalization [9] is effective at accelerating and improving the training of deep neural networks by reducing internal covariate shift. It performs the normalization for each training minibatch along (N,H,W) dimensions in the case of NCHW format feature. Since batch normalization uses the statistics on minibatch examples, its effect is dependent on the minibatch size.
To mitigate this problem, normalization propagation [1] uses a data-independent parametric estimate of the mean and standard deviation instead of explicitly calculating from data. Normalization propagation depends on the strong assumptions that the activation values follow Gaussian distribution and the weight matrix of hidden layers are roughly incoherent.
Batch renormalization [8] introduces two extra parameters to correct the fact that the minibatch statistics differ from the population ones. It needs train the model for a certain number of iterations with batch normalization alone, without the correction, then ramp up the amount of allowed correction.
There is a family of methods which avoid normalizing along the batch dimension. Layer normalization [2] computes the mean and standard deviation along (C,H,W) dimensions. Instance normalization [27] computes the mean and standard deviation along (H,W) dimensions. When the batch size is 1, batch normalization is equivalent to instance normalization. Group normalization [29] is a intermediate state between layer normalization and instance normalization. It uses a group of channels to compute the mean and standard deviation, while layer normalization uses all channels, and instance normalization uses one channel.
Weight normalization [22] normalizes the filter weights instead of the activations by re-parameterizing the incoming weight vector. Cosine normalization [14] normalizes both the filter weights and the activations by using cosine similarity or Pearson correlation coefficient instead of dot product in neural networks.
Kalman normalization [28] estimates the mean and standard deviation of a certain layer by considering the distributions of all its preceding layers, mimicking the merits of Kalman Filtering Process. It takes much overhead since it introduces a transition matrix and a covariance matrix to carry out Kalman transform, and needs sampling according to the distribution of previous layer before Kalman transform. On the other hand, it can be combined with other normalization, e.g. batch Kalman normalization, group Kalman normalization. Extended batch normalization could also be equipped with Kalman normalization.
Some researches try to use other statistics instead of mean and standard deviation in normalization. Instead of the standard L 2 batch normalization, [7] uses normalization in L 1 and L ∞ spaces, and shows that can improve numerical stability in low-precision implementations as well as provide computational and memory benefits. Generalized batch normalization [30] investigates a variety of alternative deviation measures for scaling and alternative mean measures for centering.
Batch-instance normalization [18] uses a learnable gate parameter to combine batch and instance normalization together, and switchable normalization [15] uses learnable parameters to combine batch, instance and layer normalization. Virtual batch normalization [21] and spectral normalization [17] focus on the normalization in generative adversarial networks. Self-Normalizing [10] focuses on standard feed-forward neural networks (fully-connected networks). Recurrent batch normalization [4] modifies batch normalization to use in recurrent networks. EvalNorm [25] estimates corrected normalization statistics to use for batch normalization during evaluation. [19] provides a unifying view of the different normalization approaches. [23], [16] and [3] try to explain how batch normalization works.

Extended Batch Normalization
We first describe some notations which will be used next. In the case of NCHW format feature, let U denote the universal set of the features in the same layer, and i = (i N , i C , i H , i W ) refer to a 4D tensor indexing the features, N is the batch dimension, C is the channel dimension, H and W are the spatial height and width dimensions. A family of normalization can be formalized as: Where x is the feature computed by a layer, and i is an index. µ is the mean and σ is the standard deviation (std). S i is the set of pixels from which the mean is computed, and S i is the set of pixels from which the standard deviation is computed. γ and β are learned parameters of affine transform.
In extended batch normalization, the set S i and S i are defined as: Where i C (and k C ) refer to the sub-index of i (and k) along the C dimension, U is the universal set of the features.
The key difference between extended batch normalization and other normalization methods is that extended batch normalization computes the mean and the standard deviation from different set of pixels. As the same as batch normalization, extended batch normalization computes the mean along the (N, H, W) dimensions. However, it computes the standard deviation along the (N,C,H,W) dimensions, thus enlarges the pixel set from which the standard deviation is computed.
The different normalization methods are shown in In the case of NC format input, e.g. input in fully-connected networks, extended batch normalization computes the mean along the (N) dimension, and computes the standard deviation along the (N, C) dimensions.

Small Batch Size
When training with batch normalization, examples are seen in conjunction with each other in the minibatch. The model looks at multiple training examples in combination, rather than in isolation. The coordination between examples helps the learning process. Moreover, the random selection of examples in the minibatch brings the sampling noises, and that provides similar regularization benefits as Dropout [26]. However, when the batch size is small, the noises are too much and make inaccurate batch statistics estimation.
Let m N refer to the size of N dimension (batch size), m C refer to the size of C dimension, m H refer to the size of H dimension, m W refer to the size of W dimension, m refer to the size of S i . Then, in batch normalization, When m N is small, the m is small. That is to say, the pixel set from which the mean and the standard deviation are computed is small. That makes the estimation of mean and standard deviation inaccurate. In layer normalization, The m in layer normalization is independent on m N , thus has no problem caused by small batch size. However, normalizing along the channel dimension increases the correlation between the channels since they share the same mean and standard deviation. Correlation between features is harmful for training neural networks [13]. Group normalization alleviates this problem by normalizing along a group of channels. The size m in group normalization is: In the same group, the correlation between the channels still exists. Moreover, there is a extra hyper parameter G to be tuned. When G is large, the m is small. Then the estimation of mean and standard deviation may be inaccurate. As G equals to m C , group normalization becomes instance normalization. When G is small, the number of channels in the same group increase, but this aggravate the problem of correlation. When G equals to 1, group normalization becomes layer normalization. Lastly, for low resolution input, the m H * m W is small, that also makes the estimation of the mean and the standard deviation inaccurate. The extreme situation is m H * m W = 1, the input becomes 1-dimension vector.
In extended batch normalization, the mean is computed along (N, H, W) dimensions as the same as batch normalization. Thus it maintains the merits of batch normalization. On the other hand, extended batch normalization enlarges the pixel set S i from which the standard deviation is computed along (N, C, H, W) dimensions, thus alleviates the problem caused by small batch size or low resolution. The size of S i is:

Inference
At inference time for extended batch normalization, the mean and the standard deviation are pre-computed from the training set by the moving average as the same as batch normalization.
Where µ r refers to the moving average of the mean, σ r refers to the moving average of the standard deviation, µ b refers to the mean of a batch, σ b refers to the standard deviation of a batch, t refers to the number of times of computation, and ρ is a momentum constant less than one.
There is no need to compute the mean and the standard deviation at inference time comparing to group normalization. Moreover, since the mean and the standard deviation are pre-computed and fixed at inference time, the normalization can be fused into convolution operation. That is very helpful to speed up the inference especially on the mobile or embedded devices.

Experiment
In this section, we compare extended batch normalization (EBN) with batch normalization (BN) and group normalization (GN) on the datasets of MNIST, CIFAR-10/100, STL-10, and ImageNet, respectively. We use Pytorch 1.1.0 in our experiments 3 . BN and GN have already been implemented by Pytorch. For BN, we use the default settings in Pytorch. For EBN, we use the same settings as BN. For GN, we set the group G to 32 which is used in the original paper [29].

MNIST
The MNIST [12] data set consists of 28x28 pixel handwritten digit black and white images. The task is to classify the images into 10 digit classes. There are 60, 000 training images and 10, 000 test images in the MNIST data set. Each channel of the input is normalized into 0 mean and 1 std globally.
Our purpose is to compare different normalization methods, rather than renew the record. We used a very simple network, with a 28x28 binary image as input, and 4 fully-connected hidden layers with 128 hidden units each. Normalization followed by ReLU activation is used each layer. We evaluate the batch sizes of 128 and 4 with different normalization. For the batch size of 128, the learning rate is set to 0.1. And for the batch size of 4, the learning rate is set to 0.1 * 4/128, following the linear scaling rule [5] to adapt to batch size changes. We train the network for 50 epochs using SGD with 0.5 momentum. We use 1 GPU to train all models.
The results of MNIST are shown in Fig 2 and Table 1. For the batch size of 128, shown in Fig 2(a), we can see BN and EBN achieve similar performances which are better than GN. For the batch size of 4, shown in Fig 2(b), the test accuracy of BN has large fluctuation. EBN achieves the most stable and highest accuracy. We show the accuracy numbers in Table 1. To reduce random variations, we report the average accuracy of the final 5 epochs (This is adopted in our following experiments). With the batch size of 128, EBN achieves 98.37% test accuracy, 0.52% higher than GN, which achieves 97.85%. With the batch size of 4, the test accuracies of all normalization methods have decreased. Compared to the batch size of 128, BN, EBN and GN reduces 3.76%, 0.3% and 0.07% respectively. EBN is still better than GN by 0.29%.  Summary In the case of fully-connected network, n H * n W = 1. The size of pixel set, from which the statistics are computed for batch normalization, depends only on the batch size. Thus the performance of BN is very poor when using small batch size. EBN maintains the advantage of BN in case of the large batch size. Meanwhile, it alleviates the problem caused by small batch size.

CIFAR
CIFAR-10 [11] is a data set of natural 32x32 RGB images in 10 classes with 50, 000 images for training and 10, 000 for testing. CIFAR-100 is similar with CIFAR-10 but with 100 classes. To augment data, the training images are padded with 0 to 36x36 and then randomly cropped to 32x32 pixels. Then randomly horizontal flipping is made. Each channel of the input is normalized into 0 mean and 1 std globally. Weight decay of 0.0005, and SGD with 0.9 momentum are used.
On CIFAR-10 and CIFAR-100, We evaluate both ResNet18 [6] and VGG16 [24] with BN, EBN and GN, respectively. For the batch size of 128, the initial learning rate is set to 0.1. And for the batch size of 4, the initial learning rate is set to 0.1 * 4/128, following the linear scaling rule. We train the network for 200 epochs, and decrease the learning rate by 10x at 100 and 150 epochs.. The training of VGG16 with GN is failed when using the initial learning rate of 0.1, thus we decrease the initial learning rate to 0.01 (we also try the initial learning rate of 0.05, but the training is still failed) when training the VGG16 with GN. We use 1 GPU to train all models.

Results of ResNet18
The results of ResNet18 on CIFAR-10 are shown in Fig 3 and Table 2. From Fig 3(a), we can see BN and EBN achieve close performances with the large batch size of 128. EBN has 94.96% test accuracy, slightly better than BN, and better than GN by 1.62%. As shown is Fig 3(b), with the small size of 4, BN also has large fluctuation of test accuracy, while GN achieves better performance than with the batch size of 128. Stably, EBN achieves the best test accuracy 94.92% in the case of the small batch size. The results of ResNet18 on CIFAR-100 are shown in Fig 4 and Table 3. With the batch size of 128, BN achieves the best test accuracy of 77.50%. EBN has 76.53%, worse than BN by 0.97%, but better than GN by 2.68% which only has 73.85%. When the batch size decreases to 4, BN' performance decreases,   Results of VGG16 The results of VGG16 on CIFAR-10 are shown in Fig 5 and Table 4.With the large batch size of 128, BN achieves best accuracy 93.71%. EBN have 93.41% test accuracy, worse than BN by 0.,3%, but better than GN by 1.4%. With the small size of 4, BN' accuracy decreases to 93.53%, while EBN' increases to 93.55%. They are better than the GN' accuracy 92.12%.  The results of VGG16 on CIFAR-100 are shown in Fig 6 and    Summary With the large batch size, BN works well both in ResNet18 and VGG16. EBN performs slightly worse than BN, but better than GN with the large batch size. Finally, EBN performs better than both BN and GN when using the small batch size.

STL-10
The STL-10 dataset is a data set of natural 96x96 RGB images in 10 classes. Each class has fewer labeled training examples, but a very large set of unlabeled examples. We use only the labeled examples (500 training images, 800 test images per class) in our experiments. To augment data, the training images are padded with 0 to 100x100 and then randomly cropped to 96x96 pixels. We evaluate ResNet18 with different normalization methods. The experiment settings are the same as CIFAR-10.
The results of STL-10 are shown in Fig 7 and Table 6. With the batch size of 128 and 4, BN achieves best performance, and EBN performs better than GN. With the batch size of 4, all normalizations achieve better results than with the batch size of 128. STL-10 has fewer labeled training examples in total, thus the batch size could be smaller when training. That is to say, the batch size of 4 has not triggered the problem of small batch size of batch normalization. When using the batch size of 2, the performance of BN decreases to 76.91%, and EBN achieves highest accuracy 77.96%.  Summary The STL-10 dataset has higher resolution and fewer total training examples comparing to CIFAR dataset. Relatively, the batch size of 4 is not small enough to deteriorate the effect of BN. When using smaller batch size of 2, EBN achieves the best performance.

ImageNet
ImageNet classification dataset [20] has 1.28M training images and 50,000 validation images with 1000 classes. To augment data, the training images are cropped with random size of 0.08 to 1.0 of the original size and a random aspect ratio of 3/4 to 4/3 of the original aspect ratio, and then resized to 224x224. Then random horizontal flipping is made. The validation image is resized to 256x256, and then cropped by 224x224 at the center. Each channel of the input is normalized into 0 mean and 1 std globally. Weight decay of 0.0001, and SGD with 0.9 momentum are used.
On ImageNet, we evaluate the ResNet18 with BN, EBN and GN. We use 4 GPUs. We evaluate batch sizes of 64 and 4 images per GPU. The mean and the standard deviation of BN and EBN are computed within each GPU. For the batch size of 64, the initial learning rate is set to 0.1. And for the batch size of 4, the initial learning rate is set to 0.1 * 4/64, following the linear scaling rule. We train the network for 100 epochs, and decrease the learning rate by 10x at 30, 60 and 90 epochs.
The results of ImageNet are shown in Fig 8 and Table 7. From Fig 8(a), we can see EBN achieves close performance to BN, better than GN, in the case of large batch size. From Fig 8(b), we can see EBN achieves close performance to GN, better than BN, in the case of small batch size. As shown in Table 7, with the batch size of 64 per GPU, BN achieves the best validation accuracy of 70.37%. EBN has 70.12%, worse than BN by 0.25%, but better than GN by 1.35%. With the batch size of 4 per GPU, the accuracy of BN decreases to 65.78%. GN achieves the best accuracy of 69.08%. EBN achieves 68.54%, worse than GN by 0.54%, better than BN by 2.76%.

Summary
In the case of large batch size, EBN achieves close performance to BN, better than GN. In the case of small batch size, EBN achieves close performance to GN, better than BN.

Conclusion
In this paper, we propose a simple but effective method, called extended batch normalization. The key difference from other normalization methods is that extended batch normalization computes the mean and the standard deviation from different set of pixels. To maintain the advantage of batch normalization, extended batch normalization computes the mean along the (N, H, W) dimensions just as the standard batch normalization. To alleviate the problems caused by small batch size, extended batch normalization enlarges the pixel set from which the standard deviation is computed along (N, C, H, W) dimensions. The experiments show that extended batch normalization alleviates the problem of batch normalization with small batch size while achieving close performances to batch normalization with large batch size. Many other techniques could be equipped with extended batch normalization, e.g. kalman normalization [28], switchable normalization [15]. Moreover, as the same as batch normalization, the moving average of minibatch statistics is maintained during training and used during evaluation in extended batch normalization. As pointed by [8] and [25], that inconsistence hurts the performance of batch normalization in the case of small batch size. We will investigate the inconsistence between the training and the evaluation in extended batch normalization.