Contrastive Neural Processes for Self-Supervised Learning

Konstantinos Kallidromitis, Denis A. Gudovskiy, Kazuki Kozuka, Ohama Iku, Luca Rigazio

Abstract

Self-supervised learning (SSL) has achieved remarkable success in computer vision by leveraging data augmentations to learn invariant representations. However, designing effective augmentations for time series data remains a significant challenge due to the lack of universal, domain-agnostic transformations. We present Contrastive Neural Processes (ContrNP), a framework that integrates the forecasting capabilities of Neural Processes with a contrastive objective. By utilizing random sampling as an implicit augmentation strategy, ContrNP learns robust representations without the need for hand-crafted data distortions. Our results across medical, industrial, and audio datasets demonstrate state-of-the-art performance and exceptional label efficiency.

Introduction

The success of SSL in domains like image recognition is heavily predicated on the availability of semantic-preserving augmentations. In time series analysis, however, common transformations such as noise injection or time-warping can fundamentally change the underlying signal's meaning, making them difficult to generalize across tasks. Contrastive Neural Processes (ContrNP) addresses this by reframing the problem: instead of altering the data, the model learns from different "views" generated through random sampling of the context and target sets.

Methods

ContrNP combines the generative modeling of Neural Processes (NPs) with the discriminative power of contrastive learning. The primary innovation is "out-of-context sampling," where multiple subsets of a single data stream are used as positive pairs in a contrastive framework.

Figure 5: The context set sampling mechanism used in ContrNP to create diverse views of the same signal without manual augmentations.

The model is trained using a dual-objective loss function:

  1. Negative Log-Likelihood (NLL): A forecasting loss that ensures the model can accurately reconstruct missing parts of the signal, thereby capturing local temporal dependencies.
  2. Normalized Temperature-scaled Cross Entropy (NT-Xent): A contrastive loss that aligns representations of the same signal while separating those of different signals in the latent space.

The architecture specifically employs Convolutional Conditional Neural Processes (ConvCNP) to exploit translation equivariance, which is essential for modeling periodic and shifting patterns common in time series data.

Datasets

The framework was evaluated on three distinct real-world challenges:

  • MIT-BIH Atrial Fibrillation (AFDB): ECG recordings for arrhythmia detection.
  • IMS Bearing: Vibration data for industrial fault diagnosis.
  • Urban8K: A diverse collection of urban environmental sounds.

Results

ContrNP consistently outperforms existing SSL methods and demonstrates high robustness to label scarcity.

Figure 1: Accuracy comparison across different label percentages (left) and the model's ability to reconstruct a signal from context points (right).

On the AFDB dataset, ContrNP achieved an accuracy of 94.2%, significantly surpassing SimCLR (82.3%) and TNC (74.5%). Notably, the model maintains high performance even when fine-tuned with only 10% of available labels, matching the performance of fully supervised models. In industrial applications (IMS Bearing), ContrNP's augmentation-free approach proved superior to methods relying on traditional time-warping, which often failed to capture critical mechanical failure patterns.

Conclusion

Contrastive Neural Processes provide a robust, task-agnostic framework for self-supervised learning in time series. By leveraging the internal logic of Neural Processes for both forecasting and contrastive alignment, the model achieves superior representation learning without the "augmentation headache." Future work will explore the sensitivity of the loss-balancing hyperparameter and the potential application of this sampling-based approach to other data modalities.

Summary updated

BibTeX
@inproceedings{kallidromitis2021contrastive,
  author = {Konstantinos Kallidromitis and Denis A. Gudovskiy and Kazuki Kozuka and Ohama Iku and Luca Rigazio},
  title = {{Contrastive Neural Processes for Self-Supervised Learning}},
  booktitle = {ACML},
  year = {2021},
}
Figure