Video understanding, tracking, generation, and world models · Video self-supervision · VID022 · Training method
Contrastive Video Representation Learning (CVRL)
Learns by bringing augmented views from the same video together and separating views from other videos. The important video-specific contribution is how temporal sampling and spatial augmentations preserve coherent…
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Learns by bringing augmented views from the same video together and separating views from other videos. The important video-specific contribution is how temporal sampling and spatial augmentations preserve coherent motion across frames.
Question / objective
Learn transferable video representations from automatically constructed targets or weak cross-modal supervision. This is a learning or inference objective, not a test of a statistical null hypothesis.
Method type and supervision
training-method · Video self-supervision. Self-supervised pretraining; cross-modal variants also use weak paired language supervision.
Architecture / computational structure
Shared video encoder, projection head and paired-view contrastive training pipeline.
Assumptions
Inputs must satisfy the temporal, modality and annotation protocol described below. Augmentations must preserve task-relevant action semantics. Same-video positives may include unrelated events; different-video negatives may share actions. Validation labels should not determine pretraining examples.
Formula / computational definition
, with normalized embedding similarity , positive view and temperature . The projection head need not be the deployed representation.
Parameters and notation
Learned/estimated quantities: Encoder and predictor/projection weights are learned; target-network EMA values are state updates, and masks/negative policies are design choices. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Temporal overlap, spatially consistent augmentation, batch size, temperature and projection width affect learning.
Fitting, fine-tuning, and adaptation
Pretrain with domain-appropriate augmentations; discard or separately assess the projection head. For downstream tasks, fit a frozen probe before unfreezing the encoder. Use a separate adaptation validation split, monitor the target metric and retention of previously useful behavior, and save the exact preprocessing and training configuration.
How to use and calibrate
Fix the input protocol and target before fitting; choose design settings on held-out source videos, then freeze the evaluation procedure. Report linear probes, fine-tuning and nearest-neighbor retrieval with identical feature extraction across baselines.
Example application
Build a video embedding for nearest-neighbor retrieval without class labels.
Interpretation / pitfalls
Watch out
An optimized training objective or a favorable example does not establish generalization. Report linear probes, fine-tuning and nearest-neighbor retrieval with identical feature extraction across baselines. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.
Python and R code examples
Component: Build a same-video contrastive positive against other videos. Dependencies: NumPy in Python; base R in R; run the shared setup above. Python component: executed successfully. R component: unexecuted. No complete model training or pretrained inference was executed.
Full implementation route — Python: Use temporally coherent clip augmentation and a contrastive training loop with carefully indexed positives. R: Implement the contrastive objective in R and bridge neural training; do not resample each frame independently unless studying that ablation.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Build a same-video contrastive positive against other videos.
Shared setup for this chapter
import numpy as np
def softmax(x):
z = np.asarray(x, dtype=float)
e = np.exp(z - z.max())
return e / e.sum()
views = np.array([[1.,0.],[.8,.2],[0.,1.],[-1.,0.]])
views /= np.linalg.norm(views,axis=1,keepdims=True)
scores = views[1:]@views[0]/0.2 # first candidate is positive
print("CVRL-style contrastive component",-np.log(softmax(scores)[0]))
Component demo, not a trained model — Build a same-video contrastive positive against other videos.
Shared setup for this chapter
softmax <- function(x) {
e <- exp(x - max(x))
e / sum(e)
}
views <- rbind(c(1,0),c(.8,.2),c(0,1),c(-1,0))
views <- views/sqrt(rowSums(views^2))
scores <- as.vector(views[-1,]%*%views[1,])/.2
print(-log(softmax(scores)[1]))
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry VID022.