Contrastive Weight Regularization for Large Minibatch SGD

Qiwei Yuan, Weizhe Hua, Yi Zhou, Cunxi YuarXiv 2020

Introduction

Modern deep learning relies heavily on distributed training across massive datasets. To maximize hardware utilization, researchers often employ large minibatch sizes, sometimes reaching tens of thousands of samples. However, this efficiency comes at a cost: the "generalization gap." Large-batch Stochastic Gradient Descent (SGD) tends to converge to "sharp" local minima in the loss landscape. These sharp minima are highly sensitive to data perturbations, leading to poor performance on unseen validation sets compared to models trained with smaller batches.

While techniques like learning rate scaling and noise injection have been proposed, they often fail to fully bridge this gap. This paper introduces Distinctive Regularization (DReg), a lightweight method that directly addresses the generalization gap by enhancing gradient diversity during training.

Methodology: Distinctive Regularization (DReg)

The core mechanism of DReg involves introducing architectural diversity during the training phase without increasing the complexity of the final inference model.

Layer Replication and Contrastive Loss

DReg operates by selecting a specific layer—typically one near the output of the network—and replicating it into two parallel paths with weights $W^R$ and $W^L$. During training, the standard loss function $\mathcal{L}$ (e.g., cross-entropy) is calculated for both paths. To ensure these paths learn distinct representations, a "distinctive regularization" term is added:

$$\mathcal{L}_{total} = \mathcal{L}(x, W, W^R) + \mathcal{L}(x, W, W^L) - \lambda \cdot \mathcal{L}_{DReg}(x, W^R, W^L)$$

The DReg loss term $\mathcal{L}_{DReg}$ maximizes the distance between the weights of the parallel layers, often using a squared Frobenius norm. This "push" forces the two paths to solve the same task using different internal configurations.

Comparison of vanilla SGD and DReg training and inference paths.

Gradient Diversity and Inference

By maintaining two distinct paths, the shared weights ($W$) of the network receive more diverse gradient updates. This diversity prevents the model from settling into narrow, sharp minima, instead guiding it toward flatter regions of the loss landscape that generalize better.

Crucially, DReg imposes zero inference overhead. Once training is complete, the path that performs better on the validation set is retained, and the auxiliary path is discarded. The resulting model is structurally identical to a standard vanilla architecture.

Experimental Evaluation

The authors evaluated DReg on CIFAR-10 and CIFAR-100 datasets using several prominent architectures: VGG16, ResNet18, and MobileNetV2. They tested batch sizes ranging from $2^{10}$ to $30 \times 2^{10}$.

Key Findings

  • Accelerated Convergence: DReg-trained models reached peak validation accuracy 2-3x faster than vanilla SGD. For instance, on VGG16 with large batches, DReg achieved optimal accuracy in 110 epochs, compared to 300 epochs for the baseline.
  • Scalability: The performance gains of DReg become more pronounced as the minibatch size increases, making it particularly suitable for large-scale distributed clusters.
  • Improved Generalization: In many scenarios, DReg not only trained faster but also achieved higher final validation accuracy, effectively narrowing the generalization gap.
  • Topological Sensitivity: Experiments indicated that placing the DReg layer closer to the output is most effective. Placing it too early in the network can interfere with the learning of fundamental low-level features.

Conclusion and Future Work

Distinctive Regularization offers a simple yet powerful approach to scaling SGD. By leveraging gradient diversity as a form of regularization, it allows large-batch training to achieve the generalization performance of small-batch methods with significantly faster convergence. Future research may explore the impact of multiple DReg layers or the application of this technique to non-convolutional architectures like Transformers in Natural Language Processing.

Summary updated

BibTeX
@misc{yuan2020contrastive,
  author = {Qiwei Yuan and Weizhe Hua and Yi Zhou and Cunxi Yu},
  title = {{Contrastive Weight Regularization for Large Minibatch SGD}},
  year = {2020},
  eprint = {2011.08968},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.08968},
}
Figure