Video understanding, tracking, generation, and world models · Video self-supervision · VID023 · Training method
VideoMoCo
Adapts momentum contrast to video with temporally adversarial examples and a queue designed to account for feature age.
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
Adapts momentum contrast to video with temporally adversarial examples and a queue designed to account for feature age. It targets robustness when some temporal evidence is missing, while obtaining many contrastive candidates without enormous batches.
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
Query encoder, momentum key encoder, negative queue and temporal adversarial view generator.
Assumptions
Inputs must satisfy the temporal, modality and annotation protocol described below. The momentum update alone is not the complete method. Old negatives can be stale, and deleting frames can alter the action label rather than create a harmless view.
Formula / computational definition
updates the momentum encoder. A queue-based contrastive denominator compares a query to stored keys; the paper adds temporal adversarial sampling and age-aware treatment.
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: Momentum , queue size, temporal corruption strength, temperature and key-aging policy must be specified.
Fitting, fine-tuning, and adaptation
Pretrain all required components; transfer the query encoder to downstream tasks. Queue contents are training state, not deployable parameters; reset appropriately when data distributions change. 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. Compare transfer and robustness to missing frames, isolating adversarial sampling and queue-aging effects.
Example application
Learn robust embeddings when sampled video frames are sometimes missing.
Interpretation / pitfalls
Watch out
An optimized training objective or a favorable example does not establish generalization. Compare transfer and robustness to missing frames, isolating adversarial sampling and queue-aging effects. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.
Python and R code examples
Component: Update a momentum key and illustrate queue-age weighting. 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: Implement a momentum encoder and queue, then reproduce the paper-specific temporal adversary and weighting. R: Demonstrate the momentum update and weighted contrastive denominator in R; call Python for the complete training system.
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 — Update a momentum key and illustrate queue-age weighting.
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()
key = np.array([.2,.8]); query = np.array([.7,.3]); momentum = .9
key = momentum*key+(1-momentum)*query
ages = np.array([0,1,2]); weights = .95**ages
print("updated key",key,"illustrative age weights",weights)
# The decay above is illustrative; match the paper for exact training.
Component demo, not a trained model — Update a momentum key and illustrate queue-age weighting.
Shared setup for this chapter
softmax <- function(x) {
e <- exp(x - max(x))
e / sum(e)
}
key <- c(.2,.8); query <- c(.7,.3); momentum <- .9
key <- momentum*key+(1-momentum)*query
ages <- 0:2; weights <- .95^ages
print(list(updated_key=key,illustrative_age_weights=weights))
# This decay illustrates the concept, not the complete published queue.
Sources
- Source 1openaccess.thecvf.com
From the CodeSplash reference, entry VID023.