Temporal Alignment Prediction for Supervised Representation Learning and Few-Shot Sequence Classification

Bing Su, Ji-Rong WenICLR 2022

Comparing two sequences—whether they are videos of someone performing an action or recordings of spoken words—is notoriously difficult. Sequences often have different lengths, varying sampling rates, and local "warps" (e.g., one person performs an action faster than another).

The traditional solution to this problem is Dynamic Time Warping (DTW), which finds an optimal "path" to align the sequences. However, DTW has two major flaws for modern deep learning:

  1. Speed: It relies on dynamic programming, which is slow and creates a sequential bottleneck that cannot fully utilize GPU acceleration.
  2. Differentiability: Because it solves a discrete optimization problem, it is difficult to plug into an end-to-end deep learning pipeline. You cannot easily backpropagate through a standard DTW step to train the rest of your model.

To address these issues, researchers have introduced Temporal Alignment Prediction (TAP). TAP replaces slow, optimization-based sequence alignment with a lightweight, feedforward convolutional neural network (CNN). By predicting rather than calculating the optimal alignment, TAP enables fast, fully differentiable representation learning for complex sequences.

How Temporal Alignment Prediction Works

Instead of searching for the best alignment through dynamic programming, TAP uses a lightweight CNN to predict it directly from the data.

TAP Architecture
  1. The Input: For two sequences $X$ and $Y$, the model calculates a pairwise distance matrix $D$ (representing how different frame $i$ is from frame $j$) and a temporal dissimilarity matrix $D_t$ (representing how far apart they are in time).
  2. The Predictor: These matrices are concatenated and fed into a 3-layer CNN. This network learns to recognize the visual and temporal "patterns" of a good alignment.
  3. The Output: The CNN outputs a predicted alignment matrix $T^*$. The final distance between the sequences is simply the Frobenius dot product (the sum of distances) along this predicted alignment.

Because the entire process consists of standard matrix operations and convolutions, it is fully differentiable. This allows researchers to jointly train the feature extractor (the part that processes the raw video or audio) and the alignment predictor using standard metric learning losses.

Key Insights and Advantages

  • Prediction vs. Optimization: The core innovation is recognizing that we don't need to solve for the mathematically perfect alignment every time. A neural network can learn the "intuition" of alignment from data, which is significantly faster. By turning alignment into a convolution problem, the model moves from a sequential bottleneck to a highly parallelizable operation.
  • Breaking Strict Monotonicity: Traditional DTW forces a strict chronological order. TAP is more flexible; it can handle local temporal reordering, making it more robust to "noisy" sequences or non-sequential data where strict chronological alignment might fail.
TAP vs Soft-DTW Alignment

Empirical Results

The researchers evaluated TAP across a diverse range of sequence types, including skeleton-based action sequences (MSR Action3D), audio/speech data (Spoken Arabic Digits), and complex video datasets (UCF101, HMDB51, Something-Something-v2).

  • Massive Speedups: TAP is roughly 10x faster than Soft-DTW and an order of magnitude faster than traditional DTW or Optimal Transport (OT) methods.
  • Supervised Representation Learning: TAP consistently outperformed previous alignment-based methods. For example, on the Spoken Arabic Digits dataset, it achieved a Mean Average Precision (MAP) of 0.961, significantly higher than state-of-the-art baselines.
  • Few-Shot Action Recognition: In a 5-way 1-shot action recognition task on UCF101, TAP achieved 83.5% accuracy. It outperformed complex, specialized architectures while remaining much simpler and faster.

Limitations and Future Directions

While highly effective, TAP has a few limitations. By default, the predicted distance from sequence A to B might not be identical to the distance from B to A (asymmetry). The authors mitigate this by averaging the two directions. Additionally, while the lack of strict monotonicity benefits noisy data, it might be a drawback for sequences where strict chronological order is absolute.

Future work will explore extending TAP to self-supervised learning—training on unlabeled data by aligning a sequence with a temporally warped version of itself—and applying it to cross-modal tasks, such as aligning text descriptions directly to video frames.

Summary updated

BibTeX
@inproceedings{su2022temporal,
  author = {Bing Su and Ji-Rong Wen},
  title = {{Temporal Alignment Prediction for Supervised Representation Learning and Few-Shot Sequence Classification}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=p3DKPQ7uaAi},
}
Figure