Spectral Temporal Contrastive Learning

Sacha Morin, Somjit Nath, Samira Ebrahimi Kahou, Guy WolfarXiv 2023 · DOI

Introduction

In the field of self-supervised learning (SSL), contrastive learning has emerged as the dominant paradigm for learning robust representations without human labels. Typically, these methods rely on "positive pairs" generated through random data augmentations, such as cropping or color-jittering images. However, in domains like Reinforcement Learning (RL), robotics, and video analysis, temporal proximity offers a more natural and intrinsic source of structure.

Temporal Contrastive Learning (TCL) treats observations occurring close together in time as positive pairs. While TCL has demonstrated significant empirical success, it has historically lacked the rigorous theoretical foundation that supports augmentation-based SSL. Spectral Temporal Contrastive Learning (STCL) addresses this gap by providing a theoretical bridge between sequence-based SSL and spectral graph theory, demonstrating that contrastive learning effectively recovers the underlying geometry of the environment.

Theoretical Framework

The core contribution of STCL is the formalization of temporal data as a walk on a graph. By treating transitions between states as edges, the authors establish a mathematical link between the optimization of a contrastive loss and the spectral properties of the state space.

The State Graph and Markov Chain

The authors model the data as a time-homogeneous, reversible Markov chain. In this framework, each unique observation is a vertex in a "state graph," and the edges represent the probability of transitioning between these states. This allows the researchers to apply tools from spectral graph theory to analyze the behavior of neural networks trained on temporal sequences.

The Population Loss

STCL utilizes a loss function based on low-rank matrix factorization. When expanded, this population loss decomposes into two primary components:

  1. Alignment Term: This term encourages the representations of observations that are close in time to be similar, effectively "smoothing" the representation over the graph.
  2. Negative Term: This term pushes representations of random observations—sampled from the stationary distribution—to be orthogonal, preventing the representation from collapsing into a single point.

The Spectral Connection

The key mathematical insight of the paper is that the minimizers of the STCL loss are directly related to the top eigenvectors of the normalized adjacency matrix (or equivalently, the bottom eigenvectors of the graph Laplacian). By optimizing this loss, the model performs a non-linear dimensionality reduction that captures the intrinsic manifold of the environment.

Experimental Validation

The authors validated their theoretical findings using two illustrative datasets designed to test the recovery of specific geometric structures from raw pixel data.

Rotating Teapot

This dataset consists of 400 images of a 3D teapot model rotated at various angles. The goal was to determine if the model could recover the circular (1D manifold) nature of the rotation. STCL achieved a linear probe $R^2$ of 0.98, significantly outperforming the Principal Component Analysis (PCA) baseline, which achieved 0.80. Qualitatively, STCL embeddings perfectly recovered the "ring" topology of the data.

Grid World

In this task, images were generated from an agent moving within a 2D grid environment. This tested the model's ability to map out a 2D spatial structure from high-dimensional input. STCL achieved an $R^2$ of 0.96, while PCA struggled to capture the structure, resulting in an $R^2$ of only 0.19. Visualization showed that STCL successfully reconstructed the grid topology, whereas PCA collapsed the structure, making it impossible for linear models to accurately predict the agent's coordinates.

Key Insights and Guarantees

  • Time as a Graph: The paper establishes that a sequence of data is essentially a random walk on a graph. Optimizing a contrastive loss is equivalent to performing spectral clustering or manifold learning on that graph.
  • Linear Probing Guarantees: Because the learned representations are eigenvectors, the authors can use spectral graph theory to bound the error of linear probes. If a downstream task (such as coordinate prediction) is a smooth function over the state graph, STCL is theoretically guaranteed to perform well.
  • Stationary Distribution: The theory highlights a critical implementation detail: "negative samples" should ideally be drawn from the stationary distribution of the Markov chain to maintain the alignment with spectral theory.

Limitations and Future Directions

While STCL provides a robust theoretical foundation, several challenges remain for future research:

  • Uniformity and Reversibility: The current proofs assume a uniform stationary distribution and a reversible Markov chain. Relaxing these assumptions is necessary to model more complex, directed behaviors in real-world RL.
  • Continuous State Spaces: The current formulation focuses on discrete states. Extending this to continuous spaces (e.g., high-frequency sensor data) is a logical next step.
  • Scaling to Real-World Data: Future work will need to test if these spectral properties hold up under the noise and high dimensionality of real-world video sequences.

By grounding temporal contrastive learning in spectral graph theory, STCL provides a principled framework for understanding how agents can learn the underlying geometry of their environments through simple temporal observation.

Summary updated

Abstract

Learning useful data representations without requiring labels is a cornerstone of modern deep learning. Self-supervised learning methods, particularly contrastive learning (CL), have proven successful by leveraging data augmentations to define positive pairs. This success has prompted a number of theoretical studies to better understand CL and investigate theoretical bounds for downstream linear probing tasks. This work is concerned with the temporal contrastive learning (TCL) setting where the sequential structure of the data is used instead to define positive pairs, which is more commonly used in RL and robotics contexts. In this paper, we adapt recent work on Spectral CL to formulate Spectral Temporal Contrastive Learning (STCL). We discuss a population loss based on a state graph derived from a time-homogeneous reversible Markov chain with uniform stationary distribution. The STCL loss enables to connect the linear probing performance to the spectral properties of the graph, and can be estimated by considering previously observed data sequences as an ensemble of MCMC chains.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
TeapotSTCLSTCL Probe0.98Linear-probe output; higher is better.
Source quote
L118: Teapot │ 0.80 │ 0.98 │ 1.00
Grid worldSTCLSTCL Probe0.96Linear-probe output; higher is better.
Source quote
L119: Grid World │ 0.19 │ 0.96 │ 1.00
Reported baseline / comparator measurements (2)
BenchmarkMethodMetricScoreProtocol / Evidence
TeapotPCA baseline baselinePCA Probe0.80Linear-probe output; higher is better. The caption identifies PCA as the baseline.
Source quote
L118: Teapot │ 0.80 │ 0.98 │ 1.00
Grid worldPCA baseline baselinePCA Probe0.19Linear-probe output; higher is better. The caption identifies PCA as the baseline.
Source quote
L119: Grid World │ 0.19 │ 0.96 │ 1.00
BibTeX
@misc{morin2023spectral,
  author = {Sacha Morin and Somjit Nath and Samira Ebrahimi Kahou and Guy Wolf},
  title = {{Spectral Temporal Contrastive Learning}},
  year = {2023},
  eprint = {2312.00966},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.00966},
}
Figure