D IFFERENTIABLE L EARNING - TO -N ORMALIZE VIA S WITCHABLE N ORMALIZATION
A BSTRACT
We address a learning-to-normalize problem by proposing Switchable Normalization (SN), which learns to select different normalizers for different normalization layers of a deep neural network.
SN employs three distinct scopes to compute statistics (means and variances) including a channel, a layer, and a minibatch.
SN switches between them by learning their importance weights in an end-to-end manner.
It has several good properties.
First, it adapts to various network architectures and tasks (see Fig.1).
Second, it is robust to a wide range of batch sizes, maintaining high performance even when small minibatch is presented ( e.g.images/GPU).
Third, SN does not have sensitive hyper-parameter, unlike group normalization that searches the number of groups as a hyper-parameter.
Without bells and whistles, SN outperforms its counterparts on various challenging benchmarks, such as ImageNet, COCO, CityScapes, ADE20K, and Kinetics.
Analyses of SN are also presented.
We hope SN will help ease the usage and understand the normalization techniques in deep learning.
The code of SN has been released in https://github.com/switchablenorms/ .
I NTRODUCTION
Normalization techniques are effective components in deep learning, advancing many research ﬁelds such as natural language processing, computer vision, and machine learning.
In recent years, many normalization methods such as Batch Normalization (BN) (Ioffe & Szegedy, 2015), Instance Normalization (IN) (Ulyanov et al., 2016), and Layer Normalization (LN) (Ba et al., 2016) have been developed.
Despite their great successes, existing practices often employed the same normalizer in all normalization layers of an entire network, rendering suboptimal performance.
Also, different normalizers are used to solve different tasks, making model design cumbersome.
To address the above issues, we propose Switchable Normalization (SN) , which combines three types of statistics estimated channel-wise, layer-wise, and minibatch-wise by using IN, LN, and
BN respectively.
SN switches among them by learning their importance weights.
By design, SN is adaptable to various deep networks and tasks .
For example, the ratios of IN, LN, and BN in SN are compared in multiple tasks as shown in Fig.1 (a).
We see that using one normalization method uniformly is not optimal for these tasks.
For instance, image classiﬁcation and object detection prefer the combination of three normalizers.
In particular, SN chooses BN more than IN and LN in image classiﬁcation and the backbone network of object detection, while LN has larger weights in the box and mask heads.
For artistic image style transfer (Johnson et al., 2016), SN selects IN.
For neural architecture search, SN is applied to LSTM where LN is preferable than group normalization (GN) (Wu & He, 2018), which is a variant of IN by dividing channels into groups.
The selectivity of normalizers makes SN robust to minibatch size .
As shown in Fig.1 (b), when training ResNet50 (He et al., 2016) on ImageNet (Deng et al., 2009) with different batch sizes, SN is close to the “ideal case” more than BN and GN.
For (8 , 32) as an example 1 , ResNet50 trained with
SN is able to achieve 76.9% top-1 accuracy, surpassing BN and GN by 0.5% and 1.0% respectively.
In general, SN obtains better or comparable results than both BN and GN in all batch settings.
[Figure]
p
[Figure]
cc u
[Figure]
c y
[Figure]
I m
[Figure]
g e
N e [Figure]
[Figure]
Overall this work has three key contributions . (1) We introduce Switchable Normalization (SN), which is applicable in both CNNs and RNNs/LSTMs and improves the other normalization techniques on many challenging benchmarks and tasks including image recognition in ImageNet (Russakovsky et al., 2015), object detection in COCO (Lin et al., 2014), scene parsing in Cityscapes (Cordts et al., 2016) and ADE20K
(Zhou et al., 2017), artistic image stylization (Johnson et al., 2016), neural architecture search (Pham et al., 2018) and video recognition in Kinetics (Kay et al., 2017).
The analyses of SN are presented where multiple normalizers can be compared and understood with geometric interpretation.
By enabling each normalization layer in a deep network to have its own operation , SN helps ease the usage of normalizers, pushes the frontier of normalization in deep learning, as well as opens up new research direction.
We believe that all existing models could be reexamined with this new perspective.
We’ll make the code of SN available and recommend it as an alternative of existing handcrafted approaches.
In the following sections, we ﬁrst present SN in Sec.2 and then discuss its relationships with previous work in Sec.3.
SN is evaluated extensively in Sec.4.
S WITCHABLE N ORMALIZATION (SN)
We describe a general formulation of a normalization layer and then present SN.
H
C channels
N samples
W
A General Form.
We take CNN as an illustrative example.
Let h be the input data of an arbitrary normalization layer represented by a 4D tensor ( N, C, H, W ) , indicating number of samples, number of channels, height and width of a channel respectively as shown in
Fig.2.
Let h ncij
and ˆ h ncij be a pixel before and after normalization, where n ∈ [1 , N ] , c ∈ [1 , C ] , i ∈
[1 , H ] , and j ∈ [1 , W ] .
Let µ and σ be a mean and a standard deviation.
We have
[Equation]
where γ and β are a scale and a shift parameter respectively.
(cid:15) is a small constant to preserve numerical stability.
Eqn.(1) shows that each pixel is normalized by using µ and σ , and then re-scale and re-shift by γ and β .
IN, LN, and BN share the formulation of Eqn.(1), but they use different sets of pixels to estimate µ and σ .
In other words, the num- bers of their estimated statistics are different.
In general, we have
[Equation]
where k ∈ { in , ln , bn } is used to distinguish different methods.
I k is a set pixels and | I k | denotes the number of pixels.
Speciﬁcally, I in , I ln , and I bn are the sets of pixels used to compute statistics in different approaches.
IN was established in the task of artistic image style transfer (Johnson et al., 2016; Huang & Belongie, 2017).
In IN, we have µ in , σ 2in ∈ R N × C and I in = { ( i, j ) | i ∈
[1 , H ] , j ∈ [1 , W ] } , meaning that IN has 2 NC elements of statistics, where each mean and variance value is computed along ( H, W ) for each channel of each sample.
LN (Ba et al., 2016) was proposed to ease optimization of recurrent neural networks (RNNs).
In
LN, we have µ ln , σ 2ln ∈ R N ×
and I ln
=
( c, i, j ) | c ∈ [1 , C ] , i ∈ [1 , H ] , j ∈ [1 , W ] } , implying that
LN has 2 N statistical values, where a mean value and a variance value are computed in ( C, H, W ) for each one of the N samples.
BN (Ioffe & Szegedy, 2015) was ﬁrst demonstrated in the task of image classiﬁcation (
He et al., 2016; Krizhevsky et al., 2012) by normalizing the hidden feature maps of CNNs.
In BN, we have µ bn , σ 2bn ∈ R C ×
and I bn = { ( n, i, j ) | n ∈ [1 , N ] , i ∈ [1 , H ] , j ∈ [1 , W ] } , in the sense that BN treats each channel independently like IN, but not only normalizes across ( H, W ) , but also the N samples in a minibatch, leading to 2 C elements of statistics.
2. F ORMULATION OF SN
SN has an intuitive expression
[Equation]
where Ω is a set of statistics estimated in different ways.
In this work, we deﬁne Ω = { in , ln , bn } the same as above where µ k and σ 2 k can be calculated by following Eqn.(2).
However, this strategy leads to large redundant computations.
In fact, the three kinds of statistics of SN depend on each other.
Therefore we could reduce redundancy by reusing computations,
[Equation]
showing that the means and variances of LN and BN can be computed based on IN.
Using Eqn.(4), the computational complexity of SN is O ( NCHW ) , which is comparable to previous work.
Furthermore, w k and w (cid:48) k in Eqn.(3) are importance ratios used to weighted average the means and variances respectively.
Each w k or w (cid:48)
k is a scalar variable, which is shared across all channels.
There are 3 × 2 = 6 importance weights in SN.
We have Σ k ∈ Ω w k = 1 , Σ k ∈ Ω w (cid:48) k
= 1 , and ∀ w k , w (cid:48)
k ∈ [0 , 1] , and deﬁne
[Equation]
Here each w k is computed by using a softmax function with λ in , λ ln , and λ bn as the control parameters, which can be learned by back-propagation (BP).
w (cid:48) k are deﬁned similarly by using another three control parameters λ (cid:48) in , λ (cid:48)
ln , and λ (cid:48) bn .
Training.
Let Θ be a set of network parameters ( e.g. ﬁlters) and Φ be a set of control parameters that control the network architecture.
In SN, we have Φ = { λ in , λ
ln , λ bn , λ (cid:48) in , λ (cid:48)
ln , λ (cid:48) bn } .
Training a deep network with SN is to minimize a loss function L (Θ , Φ) , where Θ and Φ can be optimized jointly by back-propagation (BP).
This training procedure is different from previous meta-learning algorithms such as network architecture search (Colson et al., 2007; Liu et al., 2018; Pham et al., 2018).
In previous work, Φ represents as a set of network modules with different learning capacities, where Θ and Φ were optimized in two BP stages iteratively by using two training sets that are nonoverlapped.
For example, previous work divided an entire training set into a training and a validation set.
However, if Θ and Φ in previous work are optimized in the same set of training data, Φ would choose the module with large complexity to overﬁt these data.
In contrast, SN essentially prevents overﬁtting by choosing normalizers to improve both learning and generalization ability as discussed below.
Analyses of SN.
To understand SN, we theoretically compare SN with BN, IN, and LN by representing them using weight normalization (WN) (Salimans & Kingma, 2016) that is independent of mean and variance.
WN is computed as v w T x (cid:107) w (cid:107) 2 , where w and x represent a ﬁlter and an image patch.
WN normalizes the norm of each ﬁlter to 1 and rescales to v .
Remark 1.
Let x be an image patch with zero mean and unit variance, w i be a ﬁlter of the ith channel, i ∈ { 1 , 2 , ..., C } , and v be the ﬁlter norm of WN.
Eqn.
(1) can be rewritten by ˆ h in = γ w i
T x (cid:107)
w i (cid:107) 2 + β ; ˆ h bn = γ w i T x (cid:107) w i (cid:107) 2 + β, s . t .
γ ≤ v ; and ˆ h ln
= γ
[Table]
2 + β .
By combining them,
SN in Eqn.
(3) can be reformulated by ˆ h
[Equation]
β, s .
t .
w bn γ ≤ v , where w in , w ln , w bn are the weights and γ ≤ v is a constraint.
[Equation]
Remark 1 simpliﬁes SN in Eqn.(3), enabling us to compare different normalizers geometrically by formulating them with respect to WN.
In Fig.3, ˆ h in of IN can be computed similarly to WN with an additional bias β , where the norms of all ﬁlters are normalized to 1 and then rescaled to γ .
As γ and v have the same learning dynamic, the length of γ would be identically to v (see w 1 , wof IN).
Moreover, ˆ h bn in BN can be rewritten as WN with regularization over γ , making it shorter than v .
Compared to IN and LN, Luo et al.
(2019) shows that the regularization of BN improves generalization and increases angle between ﬁlters, preventing them from coadaptation (see w 1 , w 2 of BN).
Furthermore, ˆ h ln in LN normalizes each ﬁlter among channels where the ﬁlter norm is less constrained than IN and BN.
That is, LN allows γ > v to increase learning ability.
Finally, ˆ h sn in SN inherits the beneﬁts from all of them and enables balance between learning and generalization ability.
For example, when the batch size is small, the random noise from the batch statistics of BN would be too strong.
SN is able to maintain performance by decreasing w bn and increasing w ln , such that the regularization from BN is reduced and the learning ability is enhanced by LN.
This phenomenon is supported by our experiment.
More results are provided in
Appendix B.
Variants of SN.
SN has many extensions.
For instance, a pretrained network with SN can be ﬁnetuned by applying the argmax function on its control parameters where each normalization layer selects only one normalizer, leading to sparse SN.
For (8 , 32) as an example, SN with sparsity achieves top-1 accuracy of 77.0% in ImageNet with ResNet50, which is comparable to 76.9% of SN without sparsity.
Moreover, when the channels are divided into groups, each group could select its own normalizer to increase representation power of SN.
Our preliminary results suggest that group
SN performs better than SN in some senses.
For instance, group SN with only two groups boosts the top-1 accuracy of ResNet50 to 77.2% in ImageNet.
The above two variants will be presented as future work due to the length of paper.
This work focuses on SN where the importance weights are tied between channels.
Inference.
When applying SN in test, the statistics of IN and LN are computed independently for each sample, while BN uses batch average after training without computing moving average in each iteration.
Here batch average is performed in two steps.
First, we freeze the parameters [Table] of the network and all the SN layers, and feed the network with a certain number of mini-batches randomly chosen from the training set.
Second, we average the means and variances produced by all these mini-batches in each SN layer.
The averaged statistics are used by BN in SN.
We ﬁnd that batch average makes training converged faster than moving average.
It can be computed by using a small amount of samples.
For example, top-1 accuracies of ResNet50 on ImageNet by using batch average with 50k and all training samples are 76.90% and 76.92% respectively.
They are trained much faster and slightly better than 76.89% of moving average.
Appendix A shows more results.
Implementation.
SN can be easily implemented in existing softwares such as PyTorch and TensorFlow.
The backward computation of SN can be obtained by automatic differentiation (AD) in these softwares.
Without AD, we need to implement back-propagation (BP) of SN, where the errors are propagated through µ k and σ 2 k .
We provide the derivations of BP in Appendix H.
R ELATIONSHIPS TO P REVIOUS W ORK
In Table 1, we compare SN to BN, IN, LN, and GN, as well as three variants of BN including Batch
Renormalization (BRN), Batch Kalman Normalization (BKN), and WN.
In general, we see that SN possesses comparable numbers of parameters and computations, as well as rich statistics.
Details are presented below.
• First, SN has similar number of parameters compared to previous methods, as shown in the ﬁrst portion of Table 1.
Most of the approaches learn a scale parameter γ and a bias β for each one of the C channels, resulting in 2 C parameters.
SN learns 6 importance weights as the additional parameters.
We see that BKN has the maximum number of C 2 parameters, as it learns a transformation matrix A for the means and variances.
WN has C scale parameters without the biases.
Furthermore, many methods have p and (cid:15) as hyper-parameters, whose values are not sensitive because they are often ﬁxed in different tasks.
In contrast, GN and BRN have to search the number of groups g or the renormalization parameters r, d , which may have different values in different networks.
Moreover, WN does not have hyper-parameters and statistics, since it performs normalization in the space of network parameters rather than feature space.
Salimans & Kingma (2016); Luo et al.
(2019) showed that WN is a special case of BN.
• Second, although SN has richer statistics, the computational complexity to estimate them is comparable to previous methods, as shown in the second portion of Table 1.
As introduced in Sec.2, IN, LN, and BN estimate the means and variances along axes ( H, W ) , ( C, H, W ) , and ( N, H, W ) respectively, leading to 2 CN , 2 N , and 2 C numbers of statistics.
Therefore, SN has 2 CN + 2 N + 2 C statistics by combining them.
Although BKN has the largest number of C + C 2 statistics, it also has the highest computations because it estimates the covariance matrix other than the variance vector.
Also, approximating the covariance matrix in a minibatch is nontrivial as discussed in (Desjardins et al., 2015; Luo, 2017b;a).
BN, BRN, and BKN also compute moving averages.
• Third, SN is demonstrated in various networks, tasks, and datasets.
Its applications are much wider than existing normalizers and it also has rich theoretical value
that is worth exploring We would also like to acknowledge the contributions of previous work that explored spatial region (Ren et al., 2016) and conditional normalization (Perez et al., 2017).
E XPERIMENTS
This section presents the main results of SN in multiple challenging problems and benchmarks, such as ImageNet (Russakovsky et al., 2015), COCO (Lin et al., 2014), Cityscapes (Cordts et al., 2016), ADE20K (Zhou et al., 2017), and Kinetics (Kay et al., 2017), where the effectiveness of SN is demonstrated by comparing with existing normalization techniques.
4. I MAGE C LASSIFICATION IN I MAGE N ET
SN is ﬁrst compared with existing normalizers on the ImageNet classiﬁcation dataset of 1k categories.
All the methods adopt ResNet50 as backbone network.
The experimental setting and more results are given in Appendix C.
Comparisons.
The top-1 accuracy on the 224 × 224 center crop is reported for all models.
SN is compared to BN and GN as shown in Table 2.
In the ﬁrst ﬁve columns, we see that the accuracy of BN reduces by 1.1% from (8 , 16) to (8 , 8) and declines to 65.3% of (8 , 2) , implying that BN is unsuitable in small minibatch, where the random noise from the statistics is too heavy.
GN obtains around 75.9% in all cases, while SN outperforms BN and GN in almost all cases, rendering its robustness to different batch sizes.
In Appendix, Fig.6 plots the training and validation curves, where SN enables faster convergence while maintains higher or comparable accuracies than those of BN and GN.
The middle two columns of Table 2 average the gradients in a single GPU by using only 16 and 32 samples, such that their batch sizes are the same as (8 , 2) and (8 , 4) .
SN again performs best in these single-GPU settings, while BN outperforms GN.
For example, unlike (8 , 4) that uses 8 GPUs,
BN achieves 76.5% in (1 , 32) , which is the best-performing result of BN, although the batch size to compute the gradients is as small as 32.
From the above results, we see that BN’s performance are sensitive to the statistics more than the gradients, while SN are robust to both of them.
The last two columns of Table 2 have the same batch size of 8, where (1 , 8) has a minibatch size of 8, while (8 , 1) is an extreme case with a single sample in a minibatch.
For (1 , 8) , SN performs best.
For (8 , 1) , SN consists of IN and LN but no BN, because IN and BN are the same in training when the minibatch size is 1.
In this case, both SN and GN still perform reasonably well, while BN fails to converge.
Ablation Study.
Fig.1 (a) and Fig.4 plot histograms to compare the importance weights of
SN with respect to different tasks and batch sizes.
These histograms are computed by averaging the importance weights of all SN layers in a network.
They show that SN adapts to various scenarios by changing its importance weights.
For example, SN prefers BN when the minibatch is sufﬁciently large, while it selects LN instead when small minibatch is presented, as shown in the green and red bars of Fig.4.
These results are in line with our analyses in Sec.2.1.
Furthermore, we repeat training of ResNet50 several times in ImageNet, to show that when the network, task, batch setting and data are ﬁxed, the importance weights of SN are not sensitive to the change of training protocols such as solver, parameter initialization, and learning rate decay.
As a result, we ﬁnd that all trained models share similar importance weights.
The importance weights in each SN layer are visualized in Appendix C.2.
Overall, examining the selectivity of SN layers discloses interesting characteristics and impacts of normalization methods in deep learning, and sheds light on model design in many research ﬁelds. [Table] [Table] [Table]
SN v.s. IN and LN.
IN and LN are not optimal in image classiﬁcation as reported in (Ulyanov et al., 2016) and (Ba et al., 2016).
With a regular setting of (8 , 32) , ResNet50 trained with IN and LN achieve 71.6% and 74.7% respectively, which reduce 5.3% and 2.2% compared to 76.9% of SN.
SN v.s. BRN and BKN.
BRN has two extra hyper-parameters, r max and d max , which renormalize the means and variances.
We choose their values as r max = 1 . 5 and d max = 0 .
5 , which work best for ResNet50 in the setting of (8 , 4) following (Ioffe, 2017).
73.7% of BRN surpasses 72.7% of BN by 1%, but it reduces 2.2% compared to 75.9% of SN.
BKN (Wang et al., 2018) estimated the statistics in the current layer by combining those computed in the preceding layers.
It estimates the covariance matrix rather than the variance vector.
In particular, how to connect the layers requires careful design for every speciﬁc network.
For ResNet50 with (8 , 32) , BKN achieved 76.8%, which is comparable to 76.9% of SN.
However, for small minibatch,
BKN reported 76.1% that was evaluated in a micro-batch setting where 256 samples are used to compute gradients and 4 samples to estimate the statistics.
This setting is easier than (8 , 4) that uses 32 samples to compute gradients.
Furthermore, it is unclear how to apply BRN and BKN in the other tasks such as object detection and segmentation.
4. O BJECT D ETECTION AND I NSTANCE S EGMENTATION IN COCO
Next we evaluate SN in object detection and instance segmentation in COCO (Lin et al., 2014).
Unlike image classiﬁcation, these two tasks beneﬁt from large size of input images, making large memory footprint and therefore leading to small minibatch size, such as 2 samples per GPU (Ren et al., 2015; Lin et al., 2016).
In this case, as BN is not applicable in small minibatch, previous work (Ren et al., 2015; Lin et al., 2016;
He et al., 2017) often freeze BN and turns it into a constant linear transformation layer, which actually performs no normalization.
Overall, SN selects different operations in different components of a detection system (see Fig.1), showing much more superiority than both BN and GN.
The experimental settings and more results are given in Appendix D.
Table 3 reports results of Faster R-CNN by using ResNet50 and the Feature Pyramid Network (FPN)
(Lin et al., 2016).
A baseline BN † achieves an AP of 36.7 without using normalization in the detection head.
When using SN and GN in the head and BN † in the backbone, BN † +SN improves the AP of BN † +GN by 0.8 (from 37.2 to 38.0).
We investigate using SN and GN in both the backbone and head.
In this case, we ﬁnd that GN improves BN † +SN by only a small margin of 0.2 AP (38.2 v.s. 38.0), although the backbone is pretrained and ﬁnetuned by using GN.
When ﬁnetuning the SN backbone, SN obtains a signiﬁcant improvement of 1.1 AP over GN (39.3 v.s.
Furthermore, the 39.3 AP of SN and 38.2 of GN both outperform 37.8 in (Peng et al., 2017), which synchronizes BN layers in the backbone ( i.e. BN layers are not frozen). [Table]
[Table] Table 4 reports results of Mask R-CNN (He et al., 2017) with FPN.
In the upper part, SN is compared to a head with no normalization and a head with GN, while the backbone is pretrained with BN, which is then frozen in ﬁnetuning ( i e. the ImageNet pretrained features are the same).
We see that the baseline BN † achieves a box AP of 38.6 and a mask AP of 34.2.
SN improves GN by 0.5 box
AP and 0.4 mask AP, when ﬁnetuning the same BN † backbone.
More direct comparisons with GN are shown in the lower part of Table 4.
We apply SN in the head and ﬁnetune the same backbone network pretrained with GN.
In this case, SN outperforms GN by 0.2 and 0.3 box and mask APs respectively.
Moreover, when ﬁnetuning the SN backbone, SN surpasses GN by a large margin of both box and mask AP (41.0 v.s. 40.2 and 36.5 v.s. 35.7).
Note that the performance of SN even outperforms 40.9 and 36.4 of the 101-layered ResNet (Girshick et al., 2018).
4. S EMANTIC I MAGE P ARSING IN C ITYSCAPES AND ADE20K
We investigate SN in semantic image segmentation in ADE20K
(Zhou et al., 2017) and Cityscapes (Cordts et al., 2016).
The empirical setting can be found in Appendix E.
Table 5 reports mIoU on the ADE20K validation set and Cityscapes test set, by using both singlescale and multi-scale testing.
In SN, BN is not synchronized across GPUs.
In ADE20K, SN outperforms SyncBN with a large margin in both testing schemes (38.7 v.s. 36.4 and 39.2 v.s. 37.7), and improve GN by 3.0 and 2.9.
In Cityscapes, SN also performs best compared to SyncBN and GN.
For example, SN surpasses SyncBN by 1.5 and 2.1 in both testing scales.
We see that GN performs worse than SyncBN in these two benchmarks.
Fig.9 in Appendix compares the importance weights of SN in ResNet50 trained on both ADE20K and Cityscapes, showing that different datasets would choose different normalizers when the models and tasks are the same.
4. V IDEO R ECOGNITION IN K INETICS
We evaluate video recognition in Kinetics dataset (Kay et al., 2017), which has 400 action categories.
We experiment with Inﬂated 3D (I3D) convolutional networks (Carreira & Zisserman, 2017) and employ the ResNet50 I3D baseline as described in (Wu & He, 2018).
The models are pretrained from ImageNet.
For all normalizers, we extend the normalization from over ( H, W ) to over ( T, H, W ) , where T is the temporal axis.
We train in the training set and evaluate in the validation set.
The top1 and top5 classiﬁcation accuracy are reported by using standard 10-clip testing that averages softmax scores from 10 clips sampled regularly.
Table 6 shows that SN works better than BN and GN in both batch sizes.
For example, when batch size is 4, top1 accuracy of SN is better than BN and GN by 1.2% and 0.5%.
It is seen that SN already surpasses BN and GN with batch size of 8.
SN with batch size 8 further improves the results.
4. O N THE OTHER T ASKS
We also evaluate SN in the tasks of artistic image stylization (Johnson et al., 2016) and efﬁcient neural architecture search (Pham et al., 2018).
The results are presented in Appendix F and G, where SN achieves competitive results.
D ISCUSSIONS AND F UTURE W ORK
This work presented Switchable Normalization (SN) to learn different operations in different normalization layers of a deep network.
This novel perspective opens up new direction in many research ﬁelds that employ deep learning, such as CV, ML, NLP, Robotics, and Medical Imaging.
This work has demonstrated SN in multiple tasks of CV such as recognition, detection, segmentation, image stylization and neural architecture search, where SN outperforms previous normalizers without bells and whistles.
The implementations of these experiments will be released.
Our analyses (Luo et al., 2018) suggest that SN has an appealing characteristic to balance learning and generalization when training deep networks.
Investigating SN facilitates the understanding of normalization approaches
A PPENDICES A I NFERENCE OF SN
[Figure]
In SN, BN employs batch average rather than moving average.
We provide comparisons between them as shown in Fig.5, where SN is evaluated with both moving average and batch average to estimate the statistics used in test.
They are used to train ResNet50 on ImageNet.
The two settings of SN produce similar results of 76.9% when converged, which is better than 76.4% of BN.
We see that SN with batch average converges faster and more stably than BN and SN that use moving average.
In this work, we ﬁnd that for all batch settings, SN with batch average provides results better than moving average.
We also found that the conventional BN can be improved by replacing moving average by using batch average.
B P ROOF OF R EMARK
Remark 1.
Suppose x to be an image patch with zero mean and unit variance, w i to be a ﬁlter of the i -th channel, i ∈ { 1 , 2 , ..., C } , and v to be the ﬁlter norm of WN.
Eqn.
(1) can be rewritten as ˆ h in = γ w i T x (cid:107) w i (cid:107) 2 + β ; ˆ h bn = γ w i T x (cid:107) w i (cid:107) 2 + β, s .
t .
γ ≤ v ; and ˆ h ln
= γ w
i T x (cid:107) w i (cid:107) 2 + (cid:80) Cj (cid:54) =
i (cid:107) w j (cid:107) 2 + β .
By combining them, Eqn. (3) is rewritten as ˆ h sn = γ
[Equation]
[Equation]
≤ v , where w ln , w bn are the weights and γ ≤ v is a constraint.
Proof.
Eqn.(1) shows that IN, LN, and BN can be generally computed as ˆ h k
= γ w i T x − µ k σ k
+ β , k ∈ { in , ln , bn } .
When x is normalized to zero mean and unit variance, we have ˆ h in = γ w
i T x (cid:107) w i (cid:107)
+ β and ˆ h ln = γ
[Equation]
to their deﬁnitions.
For BN, we follow the derivations in (Luo et al., 2019) where the batch statistics µ bn and σ bn are treated as random variables.
BN can be reformulated as population normalization (PN) and adaptive gamma decay.
Let L = 1 P (cid:80)
Pj =1 E µ bn ,σ bn (cid:96) (ˆ h j bn ) be the expected loss function of BN by integrating over random variables µ bn and σ bn .
We have L (cid:39) 1 P (cid:80) Pj =1 (cid:96) (¯ h j pn )
+ ζ ( h ) γ 2 , where ¯ h j pn = γ h j − µ P σ P + β represents population normalization (PN) with h j = w T x j .
µ P and σ P are the population mean and population standard deviation.
ζ ( h ) is a data-dependent coefﬁcient.
Therefore, ζ ( h ) γ 2 represents adaptive gamma regularization whose strength is depended on training data.
With normalized input, we have µ P = 0 and σ P = 1 .
Thus PN can be rewritten as WN, that is, ¯ h pn = γ w i
T x (cid:107)
w i (cid:107) 2 + β .
Let WN be deﬁned as v w i T x (cid:107)
w i (cid:107) 2 .
Then v in WN and γ in PN have the same learning dynamic.
However, the adaptive gamma regularization imposes the γ ≤ v constraint to
BN, since WN does not have regularization on v .
Compared to WN, we express BN as ˆ h bn = γ w i T x (cid:107) w i (cid:107) 2 + β, s .
t .
γ ≤ v .
C I MAGE N ET C. E XPERIMENTAL S ETTING
All models in ImageNet are trained on 1.2M images and evaluated on 50K validation images.
They are trained by using SGD with different settings of batch sizes, which are denoted as a 2-tuple, ( number of GPUs , number of samples per GPU ).
For each setting, the gradients are aggregated over all GPUs, and the means and variances of the normalization methods are computed in each
[Figure]
GPU.
The network parameters are initialized by following (He et al., 2016).
For all normalization methods, all γ ’s are initialized as 1 and all β ’s as 0.
The parameters of SN ( λ k and λ (cid:48) k ) are initialized as 1.
We use a weight decay of 10 − 4 for all parameters including γ and β .
All models are trained for 100 epoches with a initial learning rate of 0.1, which is deceased by 10 × after 30, 60, andepoches.
For different batch sizes, the initial learning rate is linearly scaled according to (Goyal et al., 2017).
During training, we employ data augmentation the same as (He et al., 2016).
The topclassiﬁcation accuracy on the 224 × 224 center crop is reported.
C. M
[Figure] ESULTS
Fig.6 (a) plots the validation curves of SN.
Fig.6 (b) and (c) compare the training and validation curves of SN, BN and GN in (8 , 32) and (8 , 2) respectively.
From all these curves, we see that SN enables faster convergence while maintains higher or comparable accuracies than those of BN and
GN.
Ablation Study of Importance Weights.
In particular, the selected operations of each SN layer are shown in Fig.7.
We have several observations.
First, for the same batch size, the importance weights of µ and σ could have notable differences, especially when comparing ‘res1,4,5’ of (a,b) and ‘res2,4,5’ of (c,d).
For example, σ of BN (green) in ‘res5’ in (b,d) are mostly reduced compared to µ of BN in (a,c).
As discussed in (Ioffe & Szegedy, 2015; Salimans & Kingma, 2016), this is because the variance estimated in a minibatch produces larger noise than the mean, making training instable.
SN is able to restrain the noisy statistics and stabilize training.
Second, the SN layers in different places of a network may select distinct operations.
In other words, when comparing the adjacent SN layers after the 3 × 3 conv layer, shortcut, and the 1 ×conv layer, we see that they may choose different importance weights, e.g. ‘res2,3’.
The selectivity of operations in different places (normalization layers) of a deep network has not been observed in previous work.
Third, deeper layers prefer LN and IN more than BN, as illustrated in ‘res5’, which tells us that putting BN in an appropriate place is crucial in the design of network architecture.
Although the stochastic uncertainty in BN ( i.e. the minibatch statistics) acts as a regularizer that might beneﬁt generalization, using BN uniformly in all normalization layers may impede performance.
D COCO D ATASET
SN is easily plugged into different detection frameworks implemented by using different softwares.
We implement it on existing detection softwares of PyTorch and Caffe2-Detectron (Girshick et al., 2018) respectively.
We conduct 3 settings, including setting-1:
Faster R-CNN
(Ren et al., 2015) on PyTorch; setting-2: Faster R-CNN+FPN (Lin et al., 2016) on Caffe2; and
[Figure] [Figure]
[Table]
Experimental Settings.
For setting-1 , we employ a fast implementation (Yang et al., 2017) of
Faster R-CNN in PyTorch and follow its protocol.
Speciﬁcally, we train all models on 4 GPUs and 3 images per GPU.
Each image is re-scaled such that its shorter side is 600 pixels.
All models are trained for 80k iterations with a learning rate of 0.01 and then for another 40k iterations with 0.001.
For setting-2 and setting-3 , we employ the conﬁgurations of the Caffe2-Detectron (Girshick et al., 2018).
We train all models on 8 GPUs and 2 images per GPU.
Each image is re-scaled to its shorter side of 800 pixels.
In particular, for setting-2, the learning rate (LR) is initialized as 0.02 and is decreased by a factor of 0.1 after 60k and 80k iterations and ﬁnally terminates at 90k iterations.
This is referred as the 1 x schedule in Detectron.
In setting-3, the LR schedule is twice as long as the 1 x schedule with the LR decay points scaled twofold proportionally, referred as 2 x schedule.
For all settings, we set weight decay to 0 for both γ and β following (Wu & He, 2018).
[Figure]
All the above models are trained in the 2017 train set of COCO by using SGD with a momentum of 0.9 and a weight decay of 10 − 4 on the network parameters, and tested in the 2017 val set.
We report the standard metrics of COCO, including average precisions at IoU=0.5:0.05:0.75 (AP), IoU=0.
(AP . 5 ), and IoU=0.75 (AP . 75 ) for both bounding box (AP b ) and segmentation mask (AP m ).
Also, we report average precisions for small (AP s ), medium (AP m ), and large (AP l ) objects.
Results of Setting-1.
As shown in Table 7, SN is compared with both BN and GN in the Faster
R-CNN.
In this setting, the layers up to conv4 of ResNet50 are used as backbone to extract features, and the layers of conv5 are used as the Region-of-Interest head for classiﬁcation and regression.
As the layers are inherited from the pretrained model, both the backbone and head involve normalization layers.
Different results of Table 7 use different normalization methods in the backbone and head.
Its upper part shows results of ﬁnetuning the ResNet50 models pretrained on ImageNet.
The lower part compares training COCO from scratch without pretraining on ImageNet.
In the upper part of Table 7, the baseline is denoted as BN † , where the BN layers are frozen.
We see that freezing BN performs signiﬁcantly better than ﬁnetuning BN (29.6 v.s. 19.3).
SN and GN enable ﬁnetuning the normalization layers, where SN obtains the best-performing AP of 33.0 in this setting.
Fig.8 (a) compares their AP curves.
As reported in the lower part of Table 7, SN and GN allow us to train COCO from scratch without pretraining on ImageNet, and they still achieve competitive results.
For instance, 29.5 of SN ‡ outperforms BN ‡ by a large margin of 9.5 AP and GN ‡ by 1.2 AP.
Their learning curves are compared in Fig.8 (b).
Results of Setting-2 and -3.
The results of setting-2 and setting-3 are presented in the paper.
E S EMANTIC I MAGE P ARSING
Setting.
Similar to object detection, semantic image segmentation also beneﬁts from large input size, making the minibatch size is small during training.
We use 2 samples per GPU for ADE20K and 1 sample per GPU for Cityscapes.
We employ the open-source software in PyTorch 2 and only replace the normalization layers in CNNs with the other settings ﬁxed.
For both datasets, we use
DeepLab (Chen et al., 2018) with ResNet50 as the backbone network, where output stride = 8 and the last two blocks in the original ResNet contains atrous convolution with rate = 2 and rate =respectively.
Following (Zhao et al., 2017), we employ “poly” learning rate policy with power = 0 .and
use the auxiliary loss with the weight 0 .
4 during training.
The bilinear operation is adopted to upsmaple the score maps in the validation phase.
ADE20K. SyncBN and GN adopt the pretrained models on ImageNet.
SyncBN collects the statistics from 8 GPUs.
Thus the actual “batchsize” is 16 during training.
To evaluate the performance of SN, we use SN (8 , 2) in ImageNet as the pretrained model.
For all models, we resize each image to 450 × 450 and train for 100 , 000 iterations.
We performance multi-scale testing with input size = { 300 , 400 , 500 , 600 } .
[Figure]
Cityscapes.
For all models, we ﬁnetune from their pretrained ResNet50 models.
SN ﬁnetunes from (8 , 2) .
For all models, the batchsize is 8 in ﬁnetuning.
We use random crop with the size 713 ×and train for 700 epoches.
For multi-scale testing, the inference scales are { 1 . 0 , 1 . 25 , 1 . 5 , 1 . 75 } .
Ablation Study.
Fig.9 compares the importance weights of SN in ResNet50 trained on both
ADE20K and Cityscapes.
We see that even when the models and tasks are the same, different training data encourage SN to choose different normalizers.
F A RTISTIC I MAGE S TYLIZATION
We evaluate SN in the task of artistic image stylization.
We adopt a recent advanced approach (Johnson et al., 2016), which jointly minimizes two loss functions.
Speciﬁcally, one is a feature reconstruction loss that penalizes an output image when its content is deviated from a target image, and the other is a style reconstruction loss that penalizes differences in style ( e.g. color, texture, exact boundary).
Johnson et al.
; Huang & Belongie (2017) show that IN works better than
BN in this task.
We compare SN with IN and BN using VGG16 (Simonyan & Zisserman, 2014) as backbone network.
All models are trained on the COCO dataset (Lin et al., 2014).
For each model in training, we resize each image to 256 × 256 and train for 40 , 000 iterations with a batch size setting of (1 , 4) .
We do not employ weight decay or dropout.
The other training protocols are the same as (Johnson et al., 2016).
In test, we evaluate the trained models on 512 × 512 images selected following (Johnson et al., 2016).
[Figure]
Fig.10 (a) compares the style and feature reconstruction losses.
We see that SN enables faster convergence than both IN and BN.
As shown in Fig.1 (a), SN automatically selects IN in image stylization.
Some stylization results are visualized in Fig.11.
G N EURAL A RCHITECTURE S EARCH
We investigate SN in LSTM for efﬁcient neural architecture search (ENAS) (Pham et al., 2018), which is designed to search the structures of convolutional cells.
In ENAS, a convolutional neural network (CNN) is constructed by stacking multiple convolutional cells.
It consists of two steps, training controllers and training child models.
A controller is a LSTM whose parameters are trained by using the REINFORCE (Williams, 1992) algorithm to sample a cell architecture, while a child model is a CNN that stacks many sampled cell architectures and its parameters are trained by back-propagation with SGD.
In (Pham et al., 2018), the LSTM controller is learned to produce an architecture with high reward, which is the classiﬁcation accuracy on the validation set of CIFAR-
(Krizhevsky, 2009).
Higher accuracy indicates the controller produces better architecture.
We compare SN with LN and GN by using them in the LSTM controller to improve architecture search.
As BN is not applicable in LSTM and IN is equivalent to LN in fully-connected layer ( i.e. both compute the statistics across neurons), SN combines LN and GN in this experiment.
Fig.10 (b) shows the validation accuracy of CIFAR10.
We see that SN obtains better accuracy than both LN and GN.
H B ACK -P ROPAGATION OF SN
For the software without auto differentiation, we provide the backward computations of SN below.
Let ˆ h be the output of the SN layer represented by a 4D tensor ( N, C, H, W ) with index n, c, i, j .
Let ˆ h = γ ˜ h
+ β and ˜ h
= h − µ √ σ 2 + (cid:15) , where µ = w bn µ bn + w in µ in + w ln µ ln , σ 2 = w bn σ 2bn
+ w in σ 2in + w ln σ 2ln , and w bn + w in + w ln = 1 .
Note that the importance weights are shared among the means and variances for clarity of notations.
Suppose that each one of { µ, µ bn , µ in , µ ln , σ 2 , σ 2bn , σ 2in , σ 2ln } is reshaped into a vector of N × C entries, which are the same as the dimension of IN’s statistics.
Let L be the loss function and ( ∂ L ∂µ ) n be the gradient with respect to the n -th entry of µ .
We have
[Equation]
[Equation]
The gradients for γ and β are
[Equation]
and the gradients for λ in , λ ln
[Equation]
and λ bn are
[Equation]
n [Equation] c (cid:0) [Equation]
(12) ∂ L ∂λ ln = [Equation] N
[Equation] n [Equation]
(cid:0) [Equation] N [Equation]
n [Equation] c (cid:0) ( [Equation]
∂µ [Equation] (cid:1) , (13) ∂
L ∂λ bn = [Equation] − [Equation]
n [Equation] − [Equation]
n [Equation] (cid:0) ( [Equation]
∂µ ) [Equation] ∂ [Equation]
[Equation]