Skip to content

Free labels from time: order, odd one out, speed and the future

Video's own structure gives free training questions: is this clip in order (Shuffle and Learn), which clip is wrong (Odd-One-Out), how fast is it playing (SpeedNet), what comes next (DPC). Judge the encoder by transfer, not by the puzzle.

Advanced ~14 min10 steps

What runs in CodeSplash

You will be able to

  • Explain what a pretext task is and where its labels come from
  • Describe order verification, odd-one-out and playback-speed tasks
  • Describe dense predictive coding as contrastive future prediction
  • Spot shortcuts that solve a pretext task without learning motion
  • Evaluate a pretrained encoder by downstream transfer against a random start

Read first

01

Questions with free answers

Read

Labeling actions is slow. A pretext taskPretext taskA made-up question whose answer comes free from the data, such as frame order or playback speed, used to train an encoder. asks a question whose answer the data already holds. Video is full of them, because time has structure: frames come in an order, play at a speed, and the next moment follows from this one.

An encoder trained to answer such questions might learn features useful for recognizing actions. Might: the only proof is how well it transfers to a task you care about.

02

Is this clip in order?

Read
Reference · VID018 · Explained hereShuffle and LearnLearns representations by distinguishing temporally ordered frame sequences from shuffled sequences. It replaces manual action labels with a temporal-order pretext task, after which the encoder can be transferred to…

Shuffle and Learn samples a few frames from a clip, either in their true order or shuffled, and trains a shared frame encoder plus a small head to say which, with binary cross-entropyLog lossPenalizes confident wrong probabilities heavily; lower is better.:

L=−[ylog⁡pθ+(1−y)log⁡(1−pθ)].L = -\big[y \log p_\theta + (1 - y)\log(1 - p_\theta)\big].

In the reference's toy, frames in order are paired with the same frames with the middle two swapped; with predicted validity scores for both, the loss is 0.290. The labels came from the sampling, not from a person.

03

Which one is wrong?

Read
Reference · VID019 · Explained hereOdd-One-Out NetworksPresents several video sequences and asks which one has an inconsistent temporal arrangement. The multi-choice pretext encourages comparison among sequences, rather than independently deciding whether a single clip…

Odd-One-Out shows several sequences, all in order except one, and asks which is the odd one:

L=−log⁡pθ(j∗∣S1,…,SK).L = -\log p_\theta(j^\ast \mid S_1, \ldots, S_K).

Comparing candidates, rather than judging one clip alone, pushes the encoder to notice relative differences. In the reference's toy, the second of three candidates is scrambled, and the classifier's loss for picking it is 0.418.

04

How fast is it playing?

Read
Reference · VID020 · Explained hereSpeedNetLearns video features by predicting playback speed. Sampling a recording at different temporal strides creates supervision for recognizing motion patterns without human action labels, while learned speed-sensitive…

SpeedNet makes clips at normal speed and sped up, by keeping every frame or every second frame, and trains the encoder to tell them apart. In the reference's toy at eight frames per second, normal clips sample timestamps 0.000, 0.125, 0.250, 0.375 seconds; double-stride clips reach 0.75 seconds in the same four frames.

Playback speed isn't physical speed: a slow-moving dancer filmed at a low frame rate can look "fast".

05

Ninety-nine percent on the puzzle

Predict

Predict first

An encoder reaches 99% accuracy at telling normal-speed clips from double-speed ones. Has it learned to understand motion?

Yes: the puzzle requires motion understandingNot necessarily: low-level cues can give the answer awayNo: pretext tasks never help
Reveal

Not necessarily. Skipping frames changes compression artifacts, motion blur and frame-to-frame differences in ways a network can detect without understanding what moves. Source videos also differ in frame rate. Judge the encoder on a downstream task, with controls for frame rate, appearance and compression.

06

Predict the future, contrastively

Read
Reference · VID021 · Explained hereDense Predictive Coding (DPC)Predicts future video representations from encoded past context and contrasts the predictions with other candidate features.

Dense Predictive Coding encodes past clips, aggregates them over time, and predicts the features of the next clip. The prediction must pick the true future feature out of distractors, an InfoNCEInfoNCE lossA loss that asks each row to pick out its own corrupted view among the views of every row in the batch. loss in the spirit of contrastive predictive codingContrastive predictive codingLearns by predicting a future representation from a context and picking the true future out of negatives with InfoNCE.:

L=−log⁡exp⁡(z^⊤z+/τ)∑jexp⁡(z^⊤zj/τ).L = -\log \frac{\exp(\hat z^\top z^+ / \tau)}{\sum_j \exp(\hat z^\top z_j / \tau)} .

In the reference's toy, the prediction is far closer to the true future than to the two distractors, so the loss is small: 0.0111. Future frames are fine as training targets; they must not leak into a causal model's inputs at test time.

The contrastive loss on a toy you can train here.

DExplorable · InfoNCE: temperature, negatives, collapse

How does contrastive learning learn useful embeddings without labels, and what keeps it from collapsing?

After training with this objective, where do the embeddings end up?

How sure?
0.20

Batch size

Each item's negatives are the rest of the batch.

Objective

Without labels, a batch can't tell them apart. Off: they're masked out.

0.30
300
0.80

Multiplied by min(τ, 0.15)², so low temperatures take smaller steps.

Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

07

Judge by transfer

Read

The pretext accuracy is a training signal, not a result. Report instead:

  • a downstream task (action recognition, retrieval), with the encoder frozen and fine-tuned;
  • the same network trained from a random start, at the same budget;
  • videos used for pretraining kept out of the downstream test set;
  • motion-heavy and appearance-heavy test sets separately.
08

What runs here

Read
EntryIn CodeSplash
VID018 · Shuffle and LearnExplained here
VID019 · Odd-One-Out NetworksExplained here
VID020 · SpeedNetExplained here
VID021 · Dense Predictive Coding (DPC)Explained here
09

Check: pretext tasks

Checkpoint

Check yourself

Where do the labels for Shuffle and Learn come from?

Show the answer

Answer: b

The pretext task constructs its own labels; that's what makes it self-supervised.

Check yourself

Which clips give Shuffle and Learn no useful signal?

Show the answer

Answer: a

If nothing changes, order carries no evidence; some actions are also plausible both ways.

Check yourself

What does Odd-One-Out ask that order verification doesn't?

Show the answer

Answer: b

The multiple-choice format pushes the encoder to compare sequences against each other.

Check yourself

In an odd-one-out task, the corrupted sequence always has larger frame-to-frame differences. What might the encoder learn?

Show the answer

Answer: b

Corruption that changes motion magnitude gives the answer away. Vary the corruption and test transfer.

Check yourself

A SpeedNet-style encoder labels a clip "sped up". Does that measure how fast the person moves?

Show the answer

Answer: b

Speed classes come from how frames were skipped. Real speed needs scale and frame rate.

Check yourself

Which control matters most when evaluating a playback-speed pretext model?

Show the answer

Answer: a

Frame rate and compression can reveal the answer; test on new sources where they differ.

Check yourself

What does Dense Predictive Coding predict?

Show the answer

Answer: b

It predicts future representations and uses a contrastive loss to tell the true future from others.

Check yourself

DPC trains with future clips as targets. Is that a problem for a model meant to run live?

Show the answer

Answer: b

Future targets during training are fine; future inputs during causal prediction are leakage.

Check yourself

How should you show that a pretext task helped?

Show the answer

Answer: b

Transfer against a matched baseline, on disjoint videos, is the evidence.

10

Recap

Recap
  • Pretext tasks get labels from the data: order, odd one out, playback speed, the future.
  • Low-level cues (compression, blur, frame rate) can solve them without learning motion.
  • DPC predicts future features contrastively; future targets are fine, future inputs at test time aren't.
  • Judge by downstream transfer against a random start, on disjoint videos.

Concepts in this lesson