Robust Contrastive Learning Using Negative Samples with Diminished Semantics

Songwei Ge, Shlok Kumar Mishra, Chun-Liang Li, Haohan Wang, David Jacobs

Abstract

Self-supervised models often rely on superficial textures rather than semantic shapes, a phenomenon known as "texture-addiction." This paper introduces a novel approach to break this dependency by generating non-semantic negative samples. These samples preserve an image's local texture and color statistics while destroying its global semantic meaning. By penalizing similarity to these negatives, models are forced to focus on robust semantic features like shape, leading to significant improvements in out-of-distribution robustness and standard classification accuracy.

Introduction

Convolutional Neural Networks (CNNs) frequently exploit "shortcuts" during training. Instead of learning that a "dog" is defined by its global geometry (four legs, a tail, a snout), they often learn to identify it based on local pixel statistics, such as the texture of brown fur. While effective on standard datasets like ImageNet, this reliance on texture leads to poor performance when the model encounters sketches, artistic renditions, or corrupted images where the expected texture is absent or misleading.

In contrastive learning, models learn by pulling "positive" pairs (different views of the same image) together and pushing "negative" pairs (different images) apart. Standard negative samples are typically random images from the dataset, which act as "easy" negatives. These do not sufficiently challenge the model to distinguish between core object identity and superficial style. This research proposes "harder" negatives that share non-semantic features with the original image but lack its global structure.

Proposed Method: Non-Semantic Negatives

The authors propose two primary methods for generating Non-Semantic Negatives (NS) to discourage the model from over-relying on texture:

  1. Texture-based Augmentation: Utilizing texture synthesis algorithms, the method creates images that mimic the local pixel statistics of the original but lack recognizable shapes. This effectively creates an abstract "wallpaper" of the original image's texture.
  2. Patch-based Augmentation: A more computationally efficient alternative where small patches are sampled from the original image and tiled randomly to fill a new frame. This preserves the local "feel" while completely scrambling the global geometry.
Overview of the proposed sampling strategy: (a) Input image, (b-c) standard query and positive samples, and (d-e) the proposed non-semantic negative samples.

Modified Loss Function

The standard contrastive loss (e.g., MoCo or BYOL) is modified by introducing a scaling parameter, $\alpha$. This parameter controls the penalty for high similarity between the original image and its non-semantic negative. Increasing $\alpha$ explicitly instructs the model to ignore texture-based similarities and seek higher-level semantic features to represent the image.

Experimental Results

Robustness and Generalization

The method was evaluated on ImageNet-100 and ImageNet-1K, alongside several out-of-distribution (OOD) benchmarks. On ImageNet-100, the inclusion of patch-based negatives improved accuracy on ImageNet-S (Sketches) by 5.79% and ImageNet-R (Renditions) by 5.97% compared to the MoCo-v2 baseline. Notably, this robustness did not come at the cost of standard performance; ImageNet-1K accuracy improved from 67.60% to 67.92%.

The Shape-Texture Trade-off

Analysis revealed that increasing $\alpha$ directly correlates with an increased "shape bias." While this is generally beneficial for robustness, the authors noted that for specific fine-grained classes defined primarily by texture (e.g., "window screen"), a texture-biased model may perform better. This suggests that while shape is a more robust feature, the ideal model should adaptively weigh shape and texture based on the category.

Efficiency and Implementation

Surprisingly, the simpler patch-tiling method outperformed the more complex texture synthesis algorithm. This is advantageous for practical applications as it adds negligible overhead to the training pipeline. Furthermore, the method provides high-quality hard negatives for every image, allowing for improved performance even in scenarios with limited memory banks or smaller batch sizes.

Conclusion

By introducing non-semantic negatives, this work effectively mitigates the shortcut-learning tendencies of contrastive models. The approach demonstrates that forcing a model to differentiate between an object and its own texture leads to more robust and generalizable representations. Future work may explore adaptive $\alpha$ values to handle class-specific biases and extend the concept of non-semantic negatives to other modalities like Natural Language Processing.

Summary updated

BibTeX
@inproceedings{ge2021robust,
  author = {Songwei Ge and Shlok Kumar Mishra and Chun-Liang Li and Haohan Wang and David Jacobs},
  title = {{Robust Contrastive Learning Using Negative Samples with Diminished Semantics}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=xLExSzfIDmo},
}
Figure