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.
What runs in CodeSplash
- VID018Shuffle and Learn Explained here
- VID019Odd-One-Out Networks Explained here
- VID020SpeedNet Explained here
- VID021Dense Predictive Coding (DPC) Explained here
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
Questions with free answers
ReadLabeling 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.
Is this clip in order?
ReadShuffle 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.:
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.
Which one is wrong?
ReadOdd-One-Out shows several sequences, all in order except one, and asks which is the odd one:
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.
How fast is it playing?
ReadSpeedNet 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".
Ninety-nine percent on the puzzle
PredictPredict first
An encoder reaches 99% accuracy at telling normal-speed clips from double-speed ones. Has it learned to understand motion?
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.
Predict the future, contrastively
ReadDense 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.:
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?
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.
Multiplied by min(τ, 0.15)², so low temperatures take smaller steps.
Commit your prediction above to see the result
Make your prediction to see the result.
Judge by transfer
ReadThe 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.
What runs here
Read| Entry | In CodeSplash |
|---|---|
| VID018 · Shuffle and Learn | Explained here |
| VID019 · Odd-One-Out Networks | Explained here |
| VID020 · SpeedNet | Explained here |
| VID021 · Dense Predictive Coding (DPC) | Explained here |
Check: pretext tasks
CheckpointCheck 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.
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