C ONCURRENT A DVERSARIAL L EARNING FOR L ARGEB ATCH T RAINING
A BSTRACT
Large-batch training has become a widely used technique when training neural networks with a large number of GPU/TPU processors.
As batch size increases, stochastic optimizers tend to converge to sharp local minima, leading to degraded test performance.
Current methods usually use extensive data augmentation to increase the batch size as a remedy, but we found the performance brought by data augmentation decreases with the increase of batch size.
In this paper, we propose to leverage the adversarial learning to increase the batch size in large-batch training.
Despite being a natural choice for smoothing the decision surface and biasing towards a ﬂat region, adversarial learning has not been successfully applied in large-batch training since it requires at least two sequential gradient computations at each step.
To overcome this issue, we propose a novel Concurrent Adversarial
Learning (ConAdv) method that decouples the sequential gradient computations in adversarial learning by utilizing stale parameters.
Experimental results demonstrate that ConAdv can successfully increase the batch size of ResNet-50 training on ImageNet while maintaining high accuracy.
This is the ﬁrst work that successfully scales the ResNet-50 training batch size to 96K.
I NTRODUCTION
As larger datasets and bigger models being proposed, training deep neural networks has become quite time-consuming.
For instance, training BERT (Devlin et al., 2019) takes 3 days on 16 v
TPUs.
GPT-2 (Radford et al., 2019) contains 1,542M parameters and requires 168 hours of training on 16 v3 TPUs.
With the developments of high performance computing clusters, (e.g., Google and
NVIDIA build high performance clusters with thousands of TPU or GPU chips), how to fully utilize those computing resources to accelerate the training process has become an important research topic.
Data parallelism is a commonly used technique for distributed neural network training, where each processor computes the gradient of a local batch and the gradients across processors are aggregated at each iteration for a parameter update.
Training with hundreds or thousands of processors with data parallelism is thus equivalent to running a stochastic gradient optimizer (e.g., SGD or Adam) with very large batch size, also known as large batch training .
For example, Google and NVIDIA show that by increasing the batch size to 64k on ImageNet, they can ﬁnish 90-epochs ResNet training within one minute (Kumar et al., 2021; Mattson et al., 2019).
But why can’t we inﬁnitely increase the batch size as long as more computing resources are available?
Large batch training often faces two challenges.
First, given a ﬁxed number of training epochs, increasing the batch size implies reducing the number of training iterations.
Even worse, it has been observed that large-batch training often converges to solutions with bad generalization performance (also known as sharp local minima)
(Keskar et al., 2017), possibly due to the lack of inherent noise in each stochastic gradient update.
Although this problem can be partially mitigated by using different optimizers such as LARS (You et al., 2017) and LAMB (You et al., 2019), the limit of batch size still exists.
For instance, Google utilizes several techniques, such as distributed batch normaliza- tion and mixed-precision training, to further scale the training of ResNet-50 on 4096 v3 TPU chips.
However, it can just expand the batch size to 64k (Kumar et al., 2021;
Ying et al., 2018).
To mitigate the generalization gap brought by large-batch training, data augmentation has become an indispensable component.
For instance, researchers at Facebook use augmentation to scale the training of ResNet-50 to 256 NVIDIA P100 GPUs with a batch size of 8k on ImageNet (Goyal et al., 2017).
You et al.
(2018) also use data augmentation to expand the batch size to 32k on 2048 KNL nodes.
However, in this paper we observe that when batch size is large enough (i.e., larger than 32k), data augmentation will also increase the difﬁculty of training and even have a negative impact on test accuracy.
This motivates us to study the application of adversarial training in large-batch training, which ﬁnds a perturbation within a bounded set around each sample to train the model.
Previous works ﬁnd that the adversarial training would lead to a signiﬁcant decrease in the curvature of the loss surface and make the network behave more “linearly” in the small batch size case, which could be used as a way to improve generalization (Xie et al., 2020; Moosavi-Dezfooli et al., 2019).
However, adversarial training has not been used in large-batch training since it requires a series of sequential gradient computations within each update to ﬁnd an adversarial example.
Even when conducting only one gradient ascent to ﬁnd the adversarial example, adversarial training requires two sequential gradient computations (one for adversarial example and one for weight update) that cannot be parallelized.
Therefore, even with inﬁnite computing resources, adversarial training is at least two times slower than standard training and increasing the batch size cannot compensate for that.
To resolve this issue and make adversarial training applicable for large-batch training, we propose a novel Concurrent Adversarial
Learning (ConAdv) algorithm.
We show that by allowing the computation of adversarial examples using stale weights
, the two sequential gradient computations in adversarial training can be decoupled, leading to fully parallelized computations at each step.
As a result extra processors can be fully utilized to achieve the same iteration throughput as original
SGD or
Adam optimizers.
Comprehensive experimental results on large-batch training demonstrate that
ConAdv is a better choice than existing augmentations.
Our main contributions are listed below:
• This is the ﬁrst work showing that adversarial learning can signiﬁcantly increase the batch size limit of large-batch training without using data augmentation.
• The proposed algorithm, ConvAdv, can successfully decouple the two sequential gradient computations in adversarial training and make them parallelizable.
This makes adversarial training achieve similar efﬁciency with standard stochastic optimizers when using sufﬁcient computing resources.
Furthermore, we empirically show that ConAdv achieves almost identical performance as the original adversarial training.
We also provide theoretical analysis for ConAdv.
• Comprehensive experimental studies demonstrate that the proposed method can push the limit of large batch training on various tasks.
For ResNet-50 training on ImageNet, ConAdv alone achieves 75.3% accuracy when using 96K batch size.
Further, the accuracy will rise to 76.2% when combined with data augmentation.
This is the ﬁrst method scaling ResNet-50 batch size to 96K with accuracy matching the MLPerf standard (75.9%), while previous methods fail to scale beyond 64K batch size.
B ACKGROUND 2. L ARGE -B ATCH T RAINING
Using data parallelism with SGD naturally leads to large-batch training on distributed systems.
However, it was shown that an extremely large batch is difﬁcult to converge and has a generalization gap (Keskar et al., 2017; Hoffer et al., 2017) .
Therefore, related work starts to carefully ﬁne-tune the hyper-parameters to bridge the gap, such as learning rate, momentum (You et al., 2018;
Goyal et al., 2017; Li, 2017; Shallue et al., 2018).
Goyal et al.
(2017) try to narrow the generalization gap with the heuristics of learning rate scaling.
However, there is still big room to increase the batch size.
Several recent works try to use adaptive learning rate to reduce the ﬁne-tuning of hyperparameters and further scaling the batch size to larger value (You et al., 2018; Iandola et al., 2016;
Codreanu et al., 2017; Akiba et al., 2017; Jia et al., 2018; Smith et al., 2017; Martens & Grosse,
; Devarakonda et al., 2017; Osawa et al., 2018; You et al., 2019; Yamazaki et al., 2019).
You et al.
(2017) propose Layer-wise Adaptive Rate Scaling (LARS) for better optimization and scaling to the batch size of 32k without performance penalty on ImageNet.
In addition, related work also tries to bridge the gap from the aspect of augmentation.
Goyal et al.
(2017) use data augmentation to further scale the training of ResNet-50 on ImageNet.
Yao et al.
(2018a) propose an adaptive batch size method based on Hessian information to gradually increase batch size during training and use vanilla adversarial training to regularize against the sharp minima.
However, the process of adversarial training is time-consuming and they just use the batch size of 16k in the second half of the training process (the initial batch size is 256).
How to further accelerate the training process based on adversarial training and reduce its computational burden is still an open problem.
2. A DVERSARIAL L EARNING
Adversarial training has shown great success on improving the model robustness through collecting adversarial examples and injecting them into training data (Goodfellow et al., 2015; Papernot et al., 2016; Wang et al., 2019).
Madry et al.
(2017) formulates it into a min-max optimization framework as follows:
[Equation]
(1) where D = { ( x i , y i ) } ni =1 denotes training samples and x i ∈ R d , y i ∈ { 1 , ..., Z } , δ is the adversarial perturbation, ||
· || p denotes some L p -norm distance metric, θ t is the parameters of time t and Z is the number of classes.
Goodfellow et al.
(2015) proposes FGSM to collect adversarial data, which performs a one-step update along the gradient direction (the sign) of the loss function.
Project
Gradient Descent (PGD) algorithm (Madry et al., 2017) ﬁrstly carries out a random initial search in the allowable range (spherical noise region) near the original input, and then iterates FGSM several times to generate adversarial examples.
Recently, several papers (Shafahi et al., 2019; Wong et al., 2020; Andriushchenko & Flammarion, 2020) aim to improve the computation overhead brought by adversarial training.
Speciﬁcally, FreeAdv (Shafahi et al., 2019) tries to update both weight parameter θ and adversarial example x
at the same time by exploiting the correlation between the gradient to the input and to the model weights.
Similar to Free-adv, Zhang et al.
(2019) further restrict most of the forward and backpropagation within the ﬁrst layer to speedup computation.
Wong et al.
(2020) ﬁnds the overhead could be further reduced by using single-step FGSM with random initialization.
While these works aim to improve the efﬁciency of adversarial training, they still require at least two sequential gradient computations for every step.
Our concurrent framework could decouple the two sequential gradient computations to further boost efﬁciency, which is more suitable for large-batch training.
Recently, several works (Xie et al., 2020; Cheng et al., 2021; Chen et al., 2021) show that the adversarial example can serve as an augmentation to beneﬁt the clean accuracy in the small batch size setting.
However, whether adversarial training can improve the performance of large-batch training is still an open problem.
2. MLP ERF
MLPerf (Mattson et al., 2019) is an industry-standard performance benchmark for machine learning, which aims to fairly evaluate system performance.
Currently, it includes several representative tasks from major ML areas, such as vision, language, recommendation.
In this paper, we use ResNet- (He et al., 2016) as our baseline model and the convergence baseline is 75.9% accuracy on ImageNet.
P ROPOSED A LGORITHM
In this section, we introduce our enlightening ﬁndings and the proposed algorithm.
We ﬁrst study the limitation of data augmentation in large-batch training.
Then we discuss the bottleneck of adversarial training in distributed systems and propose a novel Concurrent Adversarial Learning (ConAdv) method for large-batch training.
[Figure]
CleanData
NN
[Figure]
CleanData
ConcatData
NN
[Figure]
ConcatData
NN
CleanData
AdvData AdvData
CleanData
NN
[Figure]
3. D OES D ATA A UGMENTATION I MPROVE THE P ERFORMANCE OF L ARGE -B ATCH T RAINING ?
Data augmentation can usually improve the generalization of models and is a commonly used technique to improve the batch size limit in large-batch training.
To formally study the effect of data augmentation in large-batch training, we train ResNet-50 using ImageNet (Deng et al., 2009) by
AutoAug (AA) (Cubuk et al., 2019).
The results shown in Figure 2 reveal that although AA helps improve generalization under batch size ≤ 64K, the performance gain decreases as batch size increases.
Further, it could lead a negative effect when the batch size is large enough (e.g., 128K or 256K).
For instance, the top-1 accuracy is increased from 76 .
9% to 77 .
5% when using AA on 1k batch size.
However, it decreases from 73.2% to 72.9% under data augmentation when the batch size is 128k and drops from 64.7% to 62.5% when the batch size is 256k.
The main reason is that the augmented data increases the diversity of training data, which leads to slower convergence when using fewer training iterations.
Recent work tries to concat the original data and augmented data to jointly train the model and improve their accuracy (Berman et al., 2019).
However, we ﬁnd that concating them will hurt the accuracy when batch size is large.
Therefore, we just use the augmented data to train the model.
The above experimental results motivate us to explore a new method for large batch training.
3. A DVERSARIAL L EARNING IN THE D ISTRIBUTED S ETTING
[Figure]
Adversarial learning can be viewed as a way to automatically conduct data augmentation.
Instead of deﬁning ﬁxed rules to augment data, adversarial learning conducts gradient-based adversarial attacks to ﬁnd adversarial examples.
As a result, adversarial learning leads to smoother decision boundary (Karimi et al., 2019; Madry et al., 2017), which often comes with ﬂatter local minima (Yao et al., 2018b).
Instead of solving the original empirical risk minimization problem, adversarial learning aims to solve a min-max objective that minimizes the loss under the worst case perturbation of samples within a small radius.
In this paper, since our main goal is to improve clean accuracy instead of robustness, we consider the following training objective that includes loss on both natural samples and adversarial samples:
[Equation]
where L is the loss function and (cid:15) represents the value of perturbation.
Although many previous work in adversarial training focus on improving the trade-off between accuracy and robustness (Shafahi et al., 2019; Wong et al., 2020), recently Xie et al.
(2020) show that using split BatchNorm for adversarial and clean data can improve the test performance on clean data.
Therefore, we also adopt this split BatchNorm approach.
[Figure]
Algorithm for t = 1 , · · · , T do for x i ∈ B kc,t do
Compute Loss:
L ( θ t ; x i , y i ) using main BN,
L ka ( θ t ; ˆ x i ( θ t − τ ) , y i ) using adv BN,
L B ( θ t ) =
E B kc,t L ( θ t ; x i , y i )
+
E B ka,t (ˆ x i ( θ t − τ ) , y i )
Minimize the L B ( θ t ) and obtain g kt ( θ t ) end for for x i ∈ B kc,t + τ do
Calculate adv gradient g ka ( θ t ) on B kc,t + τ
Obtain adv examples (ˆ x i ( θ t ) , y i ) end for end for
Aggregate: ˆ g t ( θ t ) =
1 K (cid:80)
Kk
=1 ˆ g kt ( θ t )
Update weight θ t +1 on parameter sever
For Distributed Adversarial Learning (DisAdv), training data D is partitioned into N local dataset D k , and D = ∪ k
= K k
=1 D k .
For worker k , we ﬁrstly sample a mini-batch data (clean data) B kt,c from the local dataset D k at each step t .
After that, each worker downloads the weights θ t from parameter sever and then uses θ t to obtain the adversarial gradients g ka ( θ t ) = ∇ x L ( θ t ; x i , y i ) on input example x i ∈ B kt,c .
Noted that we just use the local loss E ( x i ,y i ) ∼ D k L ( θ t ; x i , y i ) to calculate the adversarial gradient g ka ( θ t ) rather than the global loss E ( x i ,y i ) ∼ D L ( θ t ; x i , y i ) , since we aim to reduce the communication cost between workers.
In addition, we use 1-step Project Gradient Descent (PGD) to calculate ˆ x ∗ i ( θ t ) =
x i + α · ∇ x L ( θ t ; x i , y i ) to approximate the optimal adversarial example x ∗ i .
Therefore, we can collect the adversarial mini-batch B ka,t = { (ˆ x ∗ i ( θ t ) , y i ) } and use both the clean example ( x i , y i )
∈ B kc,t and adversarial example (ˆ x ∗ i ( θ t ) , y i ) ∈
B ka,t to update the weights θ t .
More specially, we use main BatchNorm to calculate the statics of clean data and auxiliary BatchNorm to obtain the statics of adversarial data.
We show the workﬂow of adversarial learning on distributed systems (DisAdv) as Figure 1, and more importantly, we notice that it requires two sequential gradient computations at each step which is time-consuming and, thus, not suitable for large-batch training.
Speciﬁcally, we ﬁrstly need to compute the gradient g ka ( θ t ) to collect adversarial example ˆ x ∗ .
After that, we use these examples to update the weights θ t , which computes the second gradient.
In addition, the process of collecting adversarial example ˆ x ∗ i and use ˆ x ∗ i to update the model are tightly coupled, which means that each worker cannot calculate local loss E ( x i ,y i ) ∼ D k L ( θ t ; x i , y i ) and E ( x i ,y i ) ∼ D k L ( θ t ; ˆ x ∗ i , y i ) to update the weights θ t , until the total adversarial examples ˆ x ∗ i are obtained.
3. C ONCURRENT A DVERSARIAL L EARNING FOR L ARGE -B ATCH T RAINING
As mentioned in the previous section, the vanilla DisAdv requires two sequential gradient computations at each step, where the ﬁrst gradient computation is to obtain ˆ x ∗ i based on L ( θ t , x i , y i ) and then compute the gradient of L ( θ t , ˆ x ∗ i , y i ) to update θ t .
Due to the sequential update nature, this overhead cannot be reduced even when increasing the number of processors — with an inﬁnite number of processors the speed of two sequential computations will be twice of one parallel update.
This makes adversarial learning unsuitable for large-batch training.
In the following, we propose a simple but novel method to resolve this issue, and provide theoretical analysis on the proposed method.
Concurrent Adversarial Learning (ConAdv)
As shown in Figure 3, our main ﬁnding is that if we use stale weights ( θ t − τ ) for generating adversarial examples, then two sequential computations can be de-coupled and the parameter update step run concurrently with the future adversarial example generation step.
Now we formally deﬁne the ConAdv procedure.
Assume x
i is sampled at iteration t , instead of the current weights θ t , we use stale weights θ t − τ (where τ is the delay) to calculate the gradient and further obtain an approximate adversarial example
ˆ x i ( θ t − τ ) :
[Equation]
In this way, we can obtain the adversarial sample ˆ
x i ( θ t − τ ) through stale weights before updating the model at each step t .
Therefore, the training efﬁciency can be improved.
The structure of ConAdv as shown in Figure 1: At each step t , each worker k can directly concatenate the clean mini-batch data and adversarial mini-batch data to calculate the gradient ˆ g kt ( θ t ) and update the model.
That is because we have obtain the approximate adversarial example ˆ x i based on the stale weights θ t − τ before iteration t .
In practice, we set τ = 1 so the adversarial examples ˆ x i is computed at iteration t − 1 .
Therefore, each iteration will compute the current weight update and the adversarial examples for the next batch:
[Equation]
where
[Equation]
where B c,t = ∪ k = K k
=1 B kc,t denotes clean mini-batch of all workers and B a,t = ∪ k = K k =1 B ka,t represents adversarial mini-batch of all workers.
These two computations can be parallelized so there is no longer 2 sequential computations at each step.
In the large-batch setting when the number of workers reaches the limit that each batch size can use, ConAdv is similarly fast as standard optimizers such as SGD or Adam.
The pseudo code of proposed ConAdv is shown in Algorithm 1.
3. C ONVERGENCE A NALYSIS
In this section, we will show that despite using the stale gradient, ConAdv still enjoys nice convergence properties.
For simplicity, we will use L ( θ, x i ) as a shorthand for L ( θ ; x i , y i ) and (cid:107) · (cid:107) indicates the (cid:96) 2 norm.
Let optimal adversarial example x ∗ i = arg max x ∗ i ∈X i L ( θ t , x ∗ i ) .
In order to present our main theorem, we will need the following assumptions.
Assumption 1.
The function L ( θ, x ) satisﬁes the Lipschitzian conditions:
[Equation]
Assumption 2.
L ( θ, x ) is locally µ -strongly concave in X i
= { x ∗ : || x ∗ − x i || ∞ ≤ (cid:15) } for all i ∈ [ n ] , i.e., for any x 1 , x 2 ∈ X i ,
[Equation]
Assumption 2 can be veriﬁed based on the relation between robust optimization and distributional robust optimization in (Sinha et al., 2017; Lee & Raginsky, 2017).
Assumption 3.
The concurrent stochastic gradient ˆ g ( θ t ) = 12 |B| (cid:80) |B| i =1 (
[Equation]
L ( θ
[Equation]
x i )+ ∇
[Equation]
L ( θ
[Equation]
, ˆ x i )) is bounded by the constant M :
[Equation]
Assumption 4.
Suppose
[Equation]
+ ∇
[Equation]
L (
[Equation]
x ∗ i )) and E
[ g ( θ t )] =
∇L D ( θ t ) , where |B| represents batch size .
The variance of g ( θ t ) is bounded by σ 2 :
[Equation]
Based on the above assumptions, we can obtain the upper bound between original adversarial example x ∗ i ( θ t ) and concurrent adversarial example x ∗ i ( θ t − τ ) , where τ is the delay time.
Lemma 1.
Under Assumptions 1 and 2, we have
[Equation]
Lemma 1 illustrates the relation between x ∗ i ( θ t ) and x ∗ i ( θ t − τ ) , which is bounded by the delay τ .
When the delay is small enough, x ∗ i ( θ t − τ ) can be regarded as an approximator of x ∗ i ( θ t ) .
We now establish the convergence rate as the following theorem.
Theorem 1.
Suppose Assumptions 1, 2, 3 and 4 hold.
Let loss function L D ( θ t ) =
[Equation]
=
[Equation]
( L ( θ t ; x ∗ i , y i )
+ L ( θ t ; x i , y i )) and ˆ x i ( θ t − τ ) be the λ -solution of x ∗ i ( θ t − τ ) :
(cid:104) x ∗ i ( θ t − τ ) − ˆ x i ( θ t − τ ) , ∇ x L ( θ t − τ ; ˆ x i ( θ t − τ ) , y i ) (cid:105) ≤ λ .
Under Assumptions 1 and 2, for the concurrent stochastic gradient ˆ g ( θ ) .
If the step size of outer minimization is set to η t = η = min(1 /L, (cid:112) ∆ /Lσ 2 T ) .
Then the output of Algorithm 1 satisﬁes:
[Equation]
where L = L θθ + L xθ 2 µ L θx
Our result provides a formal convergence rate of ConAdv and it can converge to a ﬁrst-order stationary point at a sublinear rate up to a precision of L 2 θx 2 ( τML xθ Lµ + (cid:113) λµ ) 2 , which is related to τ .
In practice we use the smallest delay τ = 1 as discussed in the previous subsection.
E XPERIMENTAL R ESULTS 4. E XPERIMENTAL S ETUP
Architectures and Datasets.
We select ResNet as our default architectures.
More specially, we use the mid-weight version (ResNet-50) to evaluate the performance of our proposed algorithm.
The dataset we used in this paper is ImageNet-1k, which consists of 1.28 million images for training and 50k images for testing.
The convergence baseline of ResNet-50 in MLPerf is 75.9% top-1 accuracy in 90 epochs (i.e. ResNet-50 version 1.5 (Goyal et al., 2017)).
Implementation Details.
We use TPU-v3 for all our experiments and the same setting as the baseline.
We consider 90-epoch training for ResNet-50.
For data augmentation, we mainly consider
AutoAug (AA).
In addition, we use LARS (You et al., 2017) to train all the models.
Finally, for adversarial training, we always use 1-step PGD attack with random initialization.
[Figure]
4. I MAGE N ET T RAINING WITH R ES N ET
We train ResNet-50 with ConAdv and compare it with vanilla training and DisAdv.
The experimental results of scaling up batch size in Table 1 illustrates that ConAdv can obtain the similar accuracy compared with DisAdv and meanwhile speeding up the training process.
More specially, we can ﬁnd that the top-1 accuracy of all methods are stable when the batch size is increased from 4k to 32k.
After that, the performance starts to drop, which illustrates the bottleneck of large-batch training.
However, ConAdv can improve the top-1 accuracy and the improved performance is stable as DisAdv does when the batch size reaches the bottleneck (such as 32k, 64k, 96k), but AutoAug gradually reaches its limitations.
For instance, the top-1 accuracy increases from 74.3 to 75.3 when using ConAdv with a batch size of 96k and improved accuracy is 0 .
9% and 1 . 0% for 32k, 64k and 96k.
However, AutoAug cannot further improve the top-1 accuracy when batch size is 96k.
The above results illustrate that adversarial learning can successfully maintain a good test performance in the large-batch training setting and can outperform data augmentation.
[Table]
In addition, Figure 4(a) presents the throughput (images/ms) on scaling up batch size.
We can observe that ConAdv can further increase throughput and accelerate the training process.
To obtain accurate statistics of BatchNorm, we need to make sure each worker has at least 64 examples to calculate them (Normal Setting).
Thus, the number of cores is [Batch Size / 64].
For example, we use TPU v3-256 to train DisAdv when batch size is 32k, which has 512 cores (32k/64=512).
As shown in Figure 4(a), the throughput of DisAdv increases from 10.3 on 4k to 81.7 on 32k and
CondAdv achieve about 1.5x speedup compared with DisAdv, which veriﬁes our proposed ConAdv can maintain the accuracy of large-batch training and meanwhile accelerate the training process.
To simulate the speedup when the number of workers reach the limit that each Batch Size can use, we use a large enough distributed system to train the model with the batch size of 512, 1k and 2k on TPU v3-128, TPU v3-256 and TPU v3-512 , respectively.
The result is shown in Figure 4(b), we can obtain that ConAdv can achieve about 2x speedup compared with DisAdv.
Furthermore, in this scenario we can observe ConAdv can achieve the similar throughput as Baseline (vanilla ResNettraining).
For example, compared with DisAdv, the throughput increases from 36.1 to 71.3 when using ConAdv with a batch size of 2k.
In addition, the throughput is 75.7, which illustrates that
ConAdv can achieve a similar speed as baseline.
However, ConAdv can expand to larger batch size than baseline.
Therefore, ConAdv can further accelerate the training of deep neural network.
4. I MAGE N ET T RAINING WITH D ATA A UGMENTATION
To explore the limit of our method and evaluate whether adversarial learning can be combined with data augmentation for large-batch training, we further apply data augmentation into the proposed adversarial learning algorithm and the results are shown in Table 2.
We can ﬁnd that ConAdv can further improve the performance of large-batch training on ImageNet when combined with Autoaug (AA).
Under this setting, we can expand the batch size to more than 96k, which can improve the algorithm efﬁciency and meanwhile beneﬁt the machine utilization.
For instance, for ResNet, the top-1 accuracy increases from 74.3 to 76.2 under 96k when using ConAdv and AutoAug.
[Table]
The wall clock training times for ResNet-50 are shown in Table 3.
We can ﬁnd that the training time gradually decreases with batch size increasing.
For example, the training time of ConAdv decreases
[Table]
from 1277s to 227s when scale the batch size from 16k to 64k.
In addition, we can ﬁnd that
DisAdv need about 1.5x training time compared with vanilla ResNet-50 but ConAdv can efﬁciently reduce the training of DisAdv to a level similar to vanilla ResNet.
For instance, the training time of DisAdv is reduced from 1191s to 677s when using ConAdv.
Noted that we don’t report the clock time for vanilla ResNet-50 at 64k since the top-1 accuracy is below the MLPerf standard 75.9%.
The number of machines required to measure the maximum speed at 96K exceeds our current resources.
The comparison on 32k and 64k also can evaluate the runtime improvement.
4. G ENERALIZATION G AP
To the best of our knowledge, theoretical analysis of generalization errors in large-batch setting is still an open problem.
However, we empirically found that our method can successfully reduce the generalization gap in large-batch training.
The experimental results in Table 4 indicate that
ConAdv can narrow the generalization gap.
For example, the generalization gap is 4.6 for vanilla
ResNet-50 at 96k and ConAdv narrows the gap to 2.7.
In addition, combining ConAdv with
AutoAug, the training accuracy and test accuracy can further increase and meanwhile maintain the similar generalization gap.
[Table]
A NALYSIS OF A DVERSARIAL PERTURBATION
Adversarial learning calculates an adversarial perturbation on input data to smooth the decision boundary and help the model converge to the ﬂat minima.
In this section, we analyze the effects of different perturbation values for the performance of large-batch training on ImageNet.
The analysis results are illustrated in Table 5.
It presents that we should increase the attack intensity as the batch size increasing.
For example, the best attack perturbation value increases from 3 (32k) to 7 (96k) for ResNet-50 and from 8 (16k) to 12 (64k).
In addition, we should increase the perturbation value when using data augmentation.
For example, the perturbation value should be 3 for the original
ResNet-50 but be 5 when data augmentation is applied.
[Table]
C ONCLUSIONS
We ﬁrstly analyze the effect of data augmentation for large-batch training and propose a novel distributed adversarial learning algorithm to scale to larger batch size.
To reduce the overhead of adversarial learning, we further propose a novel concurrent adversarial learning to decouple the two sequential gradient computations in adversarial learning.
We evaluate our proposed method on ResNet.
The experimental results show that our proposed method is beneﬁcial for large-batch training.
A CKNOWLEDGEMENTS
We thank Google TFRC for supporting us to get access to the Cloud TPUs.
We thank CSCS (Swiss
National Supercomputing Centre) for supporting us to get access to the Piz Daint supercomputer.
We thank TACC (Texas Advanced Computing Center) for supporting us to get access to the Longhorn supercomputer and the Frontera supercomputer.
We thank LuxProvide (Luxembourg national supercomputer HPC organization) for supporting us to get access to the MeluXina supercomputer.
CJH and XC are partially supported by NSF under IIS-2008173, IIS-2048280 and by Army Research
Laboratory under agreement number W911NF-20-2-0158.
E THICS S TATEMENT
We do not have any potential ethics issues in this paper.
We hope to propose a novel distributed adversarial learning algorithm to accelerate large-batch training.
R EPRODUCIBILITY S TATEMENT
we list our main hyperparameters for large-batch training in Appendix A.4 (Table 6).
For experimental details, we introduce our experiment settings in section 4, such as the dataset, model architecture, data augmentation, optimizer and so on.
A A PPENDIX A. T HE PROOF OF L EMMA 1:
This completes the proof.
The proof is inspired by Sinha et al.
; Wang et al.
Under
Assumptions 1 and 2, we have
[Equation]
where x ∗ i ( θ t ) and x ∗ i ( θ t − τ ) denote the adversarial example of x i calculated by θ t and stale weight θ t − τ , respectively.
Proof:
According to Assumption
[Equation]
we have
[Equation]
In addition
[Equation]
we have
[Equation]
Combining (13) and (14)
[Equation]
we can obtain:
[Equation]
where the second inequality is due to (cid:104)∇ x L ( θ t − τ ,
x ∗ i ( θ t − τ )) , x ∗ i ( θ t ) − x ∗ i ( θ
[Equation]
− τ ) (cid:105) ≤ 0 , the third inequality holds because CauchySchwarz inequality and the last inequality follows from Assumption 1.
Therefore,
[Equation]
16) where the second inequality follows the calculation of delayed weight
[Equation]
the third inequality holds because the difference of weights is calculated with gradient ˆ g t − j
( j ∈ [1 , τ ]) and the last inequality holds follows Assumption 3.
Thus,
[Equation]
This completes the proof.
A.
Lemma 2.
Under Assumptions 1 and 2, we have L D ( θ ) is L-smooth
where L = L θθ + L xθ 2 µ L θx ,
i
[Equation]
e., for any θ 1 and θ 2 , we can say
[Equation]
Proof
Based on Lemma
[Equation]
we can obtain:
[Equation]
We can obtain for i ∈ [ n ] :
[Equation]
where the second inequality holds because Assumption
[Equation]
the third inequality holds follows Lemma
[Equation]
Therefore,
[Equation]
This completes the proof.
A.
Lemma 3.
Let ˆ x i ( θ t ) be the λ -solution of x ∗ i ( θ t ) : (cid:104) x
∗ i ( θ t ) − ˆ
[Equation]
θ
[Equation]
∇ x L ( θ t , ˆ x i ( θ t ))
(cid:105) ≤ λ .
Under
Assumptions 1 and 2, for the concurrent stochastic gradient ˆ g ( θ ) , we have
[Equation]
Proof:
[Equation]
Let ˆ x i ( θ t − τ ) be the λ -approximate of x ∗ i ( θ t − τ )
[Equation]
we can obtain:
[Equation] [Equation]
In addition
[Equation]
we can obtain:
[Equation] [Equation]
Combining 25 and 26, we have:
[Equation] [Equation]
Based on Assumption
[Equation]
we have µ (cid:107) x ∗ i ( θ t − τ ) −
[Equation]
Combining 28 with
[Equation]
we can obtain:
[Equation]
Therefore, we have
[Equation]
Thus, we can obtain
[Equation]
This completes the proof.
A. T HE PROOF OF T HEOREM 1:
Suppose Assumptions 1, 2, 3 and 4 hold
[Equation]
Let ∆ =
[Equation] [Equation]
ni =1 ( ∇L ( θ t , x i , y i ) + ∇L ( θ t , x ∗ i , y i )) .
If the step size of outer minimization is set to η t = η = min(1 /L, (cid:112) ∆ /Lσ 2 T ) , where L =
L θθ + L xθ 2 µ L θx .
Then the output of Algorithm 1 satisﬁes:
[Equation]
where L = ( ML θx L xθ /(cid:15)µ + L θθ ) .
Proof:
[Equation]
D ( θ t ) , ∇L D ( θ t ) − ˆ g ( θ t ) (cid:105) =
L D ( θ t ) − η (1 − Lη 2 ) (cid:107)∇L D ( θ t ) (cid:107) 2 + η (1 − Lη ) (cid:104)∇L D ( θ t ) , ∇L D ( θ t ) − ˆ g ( θ t ) (cid:105) + Lη2 (cid:107) ˆ g ( θ t ) − ∇L D ( θ t ) (cid:107)= L D ( θ t ) − η (1 − Lη 2 ) (cid:107)∇L D ( θ t ) (cid:107) 2 + η (1 − Lη ) (cid:104)∇L D ( θ t ) , g ( θ t ) − ˆ g ( θ t ) (cid:105) + η (1 − Lη )
(cid:104)∇L D ( θ t ) , ∇L D ( θ t ) − g ( θ t ) (cid:105) + Lη 2 2 (cid:107) ˆ g ( θ t ) − g ( θ t )
+ g ( θ t ) − ∇L D ( θ t ) (
cid:107)≤ L D ( θ t ) − η 2 (cid:107)∇L D ( θ t ) (cid:107) 22 + η 2(1 − Lη ) (cid:107) ˆ g ( θ t ) − g ( θ t ) (cid:107)+ η (1 − Lη ) (cid:104)∇L D ( θ t ) , ∇L D ( θ t ) − g ( θ t ) (cid:105) + Lη 2 ( (cid:107) ˆ g ( θ t )
− g ( θ ) (cid:107) 22 + (cid:107) g
θ t ) − ∇L D ( θ t ) (cid:107) 2 ) =
L D ( θ t ) − η 2 ||∇L D
θ t ) (cid:107) 22 + η 2 (1 + Lη ) (cid:107) ˆ g ( θ t ) − g ( θ t ) (cid:107)+ η (1 − Lη
[Equation]
Taking expectation on both sides of the above inequality conditioned on θ t , we can obtain:
[Equation]
where we used the fact
that E [ g ( θ t )] = ∇L D ( θ t ) , Assumption 2, Lemma 2 and Lemma 3.
Taking the sum of (34) over t = 0 , ..., T −
[Equation]
we obtain that:
[Equation]
Choose η = min(1 /L, (cid:113) ∆ TLσ 2 ) where ∆ =
L D ( θ 0 ) − L D ( θ T ) and L =
L θθ + L xθ 2 µ L θx , we can show that:
[Equation]
A. H YPERPARAMETERS H YPERPARAMETERS :
More specially, our main hyperparameters are shown in Table 6.
[Table]