Skip to content

Video understanding, tracking, generation, and world models · Video self-supervision · VID026 · Training method

Masked Feature Prediction (MaskFeat)

Learns video representations by predicting features of masked regions, notably histogram-of-oriented-gradient targets.

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

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 video representations by predicting features of masked regions, notably histogram-of-oriented-gradient targets. A deterministic feature target can reduce pressure to recover every pixel while retaining local shape information.

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

Masked video encoder and predictor of deterministic local feature targets.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. HOG emphasizes local edges and may miss appearance attributes needed downstream. A lower feature-reconstruction loss does not by itself demonstrate semantic or temporal understanding.

Formula / computational definition

L=∣M∣−1∑i∈M∥h^i−hi(x)∥22L=|M|^{-1}\sum_{i\in M}\|\hat h_i-h_i(x)\|_2^2, where hi(x)h_i(x) is a predefined feature such as normalized HOG and h^i\hat h_i is predicted from unmasked video context.

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: Feature cells/bins, target normalization, mask geometry, mask fraction, backbone and temporal sampling affect the learned task.

Fitting, fine-tuning, and adaptation

Transfer the encoder after dropping the feature-prediction head. Compare frozen probes and gradual unfreezing; target-feature changes require renewed pretraining rather than merely changing a classifier. 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 downstream action performance against pixel targets and alternative feature targets, using the same backbone and data budget.

Example application

Learn edge- and motion-sensitive video features from unlabeled clips.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Compare downstream action performance against pixel targets and alternative feature targets, using the same backbone and data budget. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Form a small gradient-orientation histogram target. 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 the official SlowFast MaskFeat configuration or implement deterministic HOG targets plus a masked predictor. R: Calculate small orientation histograms and feature losses in R; bridge the video encoder and validate target conventions against Python.

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.

Python

Component demo, not a trained model — Form a small gradient-orientation histogram target.

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()
gx = np.array([1.,0.,-1.,1.]); gy = np.array([0.,1.,0.,1.])
angles = np.mod(np.arctan2(gy,gx),np.pi)
hist,_ = np.histogram(angles,bins=np.linspace(0,np.pi,5),weights=np.hypot(gx,gy))
hist = hist/np.sqrt(np.sum(hist**2)+1e-8)
print("toy HOG target",hist)
R

Component demo, not a trained model — Form a small gradient-orientation histogram target.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
gx <- c(1,0,-1,1); gy <- c(0,1,0,1)
angles <- atan2(gy,gx)%%pi
bins <- pmin(4L,floor(angles/(pi/4))+1L)
histogram <- numeric(4)
for(i in seq_along(bins)) histogram[bins[i]] <- histogram[bins[i]]+sqrt(gx[i]^2+gy[i]^2)
print(histogram/sqrt(sum(histogram^2)+1e-8))

Sources

From the CodeSplash reference, entry VID026.