ImCLR: Implicit Contrastive Learning for Image Classification

John Chen, Samarth Sinha, Anastasios Kyrillidis · OpenReview

Abstract

Techniques combining multiple images as input/output have proven to be effective data augmentations for training convolutional neural networks. In this paper, we present StackMix: Each input is presented as a concatenation of two images, and the label is the mean of the two one-hot labels. On its own, StackMix rivals other widely used methods in the "Mix" line of work. More importantly, unlike previous work, significant gains across a variety of benchmarks are achieved by combining StackMix with existing Mix augmentation, effectively mixing more than two images. E.g., by combining StackMix with CutMix, test error in the supervised setting is improved across a variety of settings over CutMix, including 0.8% on ImageNet, 3% on Tiny ImageNet, 2% on CIFAR-100, 0.5% on CIFAR-10, and 1.5% on STL-10. Similar results are achieved with Mixup. We further show that gains hold for robustness to common input corruptions and perturbations at varying severities with a 0.7% improvement on CIFAR-100-C, by combining StackMix with AugMix over AugMix. On its own, improvements with StackMix hold across different number of labeled samples on CIFAR-100, maintaining approximately a 2% gap in test accuracy -- down to using only 5% of the whole dataset -- and is effective in the semi-supervised setting with a 2% improvement with the standard benchmark $\Pi$-model. Finally, we perform an extensive ablation study to better understand the proposed algorithm.

Introduction

Training deep convolutional neural networks (CNNs) requires massive amounts of labeled data to generalize effectively. Data augmentation—the process of creating synthetic training samples by perturbing existing ones—has become a cornerstone of modern deep learning. A popular family of these techniques, known as "Mix" algorithms (such as Mixup and CutMix), combines two images and their corresponding labels to encourage the model to learn smoother decision boundaries.

However, these methods often suffer from an inherent "zero-sum" information loss. Mixup achieves blending by making images transparent, which can obscure local features, while CutMix replaces patches of one image with another, occluding potentially vital information. Because these methods modify the pixel space within a single image frame, they are difficult to combine and struggle to effectively mix more than two images without significant degradation. To address this, we introduce StackMix, a simple yet effective technique that preserves all original information by concatenating images rather than blending them.

Methodology: The StackMix Algorithm

StackMix is elegantly simple in its execution. Instead of overwriting pixels, it concatenates two images—typically vertically or horizontally—to form a larger input. The target label is then calculated as the mean of the two original one-hot labels (e.g., a 50% "Cat" and 50% "Dog" label for a cat-dog stack).

The StackMix pipeline: raw inputs are augmented and then concatenated to form a single input pair, preserving the integrity of both original images.

One of the primary advantages of StackMix is its synergy with existing techniques. Because StackMix does not destroy the underlying pixels of its inputs, it can be used as a second-stage augmentation (the "A $\rightarrow$ B" approach). For instance, one can generate two distinct CutMix images and then "stack" them. This allows the network to process information from four different images in a single forward pass. Implementing StackMix requires no new hyperparameters and only minor modifications to the network's first convolutional layer to accommodate the increased input dimensions.

Experimental Results

We evaluated StackMix across several standard benchmarks, including ImageNet, Tiny ImageNet, CIFAR-10/100, and STL-10. The results consistently demonstrate that StackMix acts as a "force multiplier" when paired with other methods.

Accuracy improvements over base models across multiple datasets, highlighting the superior performance of combining StackMix with CutMix and Mixup.

Key performance highlights include:

  • ImageNet: Combining Mixup with StackMix improved top-1 accuracy by 0.8% over the standard CutMix baseline.
  • Tiny ImageNet: Achieved a significant 3.24% absolute improvement in test error compared to vanilla training.
  • Robustness: On CIFAR-100-C, combining StackMix with AugMix resulted in a 0.7% improvement, indicating better generalization to real-world corruptions like blur and noise.
  • Low-Data & Semi-Supervised Learning: In settings with limited labels (e.g., 4,000 labels on CIFAR-10), StackMix improved accuracy by over 2% using the standard $\Pi$-model.

Analysis and Discussion

Beyond raw accuracy, our analysis reveals several key insights into why StackMix is effective. Using t-SNE visualizations, we observed that the network learns disentangled embeddings, effectively separating the two stacked images in its internal representations. This suggests the model isn't just seeing a "noisy" single image but is learning to identify multiple distinct objects in different spatial locations.

Furthermore, StackMix improves robustness to distractions. By training on stacked images, the network learns to classify a target object while ignoring a "distractor" image in the other half of the stack. This spatial awareness naturally translates to better performance on corrupted or perturbed inputs.

While StackMix is highly effective, it does introduce some considerations regarding inference speed due to the larger input size. The authors suggest a test-time augmentation strategy—stacking an image with its horizontal flip—to maintain performance, though the computational cost remains higher than standard inference. Additionally, while stacking two images ($k=2$) provides substantial gains, performance tends to degrade for $k > 2$, as the inputs become too dissimilar from natural images.

Conclusion

StackMix offers a powerful, hyperparameter-free addition to the data augmentation toolkit. By preserving pixel information through concatenation, it overcomes the information-loss limitations of traditional "Mix" methods and provides a unique pathway for multi-image augmentation. Its ability to significantly boost performance across diverse datasets and training regimes makes it a compelling choice for improving CNN generalization and robustness.

Summary updated

BibTeX
@misc{chen2020imclr,
  author = {John Chen and Samarth Sinha and Anastasios Kyrillidis},
  title = {{ImCLR: Implicit Contrastive Learning for Image Classification}},
  year = {2020},
  eprint = {2011.12618},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.12618},
}

Loading related content...

Figure