Skip to content

Video understanding, tracking, generation, and world models · Action recognition · VID011 · Architecture

ViViT

Uses video tubelets and transformer factorization strategies to encode space-time information. It offers a systematic family of video-transformer designs, including separate spatial and temporal processing, for studying…

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

Uses video tubelets and transformer factorization strategies to encode space-time information. It offers a systematic family of video-transformer designs, including separate spatial and temporal processing, for studying capacity and compute tradeoffs.

Question / objective

Estimate an action label from a clip or video and determine which temporal evidence improves prediction. This is a learning or inference objective, not a test of a statistical null hypothesis.

Method type and supervision

architecture · Action recognition. Usually supervised video-label learning; image/video pretraining may use other supervision.

Architecture / computational structure

Tubelet tokenizer and a selected spatial/temporal transformer factorization.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. Large data and appropriate regularization can be important. Excessive temporal tubelet size discards fine motion; changing video length requires deliberate positional handling.

Formula / computational definition

zt,p=Evec⁡(xt:t+τ,p)+et,pz_{t,p}=E\operatorname{vec}(x_{t:t+\tau,p})+e_{t,p} embeds a tubelet spanning τ\tau frames. EE is a learned projection and ee a positional embedding; a classification head minimizes −log⁡p(y∣z)-\log p(y\mid z).

Parameters and notation

Learned/estimated quantities: Encoder filters or attention/projection weights, normalization parameters and task-head coefficients are learned; architectural dimensions and sampling rules are chosen. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Tubelet shape, factorization, number of layers, pretraining and spatial/temporal positional interpolation matter.

Fitting, fine-tuning, and adaptation

Adapt head and positional embeddings cautiously when clip geometry changes. LoRA or selective attention tuning can reduce trainable memory, but cannot remove tokenizer mismatch. 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 factorization choices at matched training and inference budgets; evaluate appearance-biased and motion-sensitive datasets separately.

Example application

Compare factorized transformers for long action clips.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Compare factorization choices at matched training and inference budgets; evaluate appearance-biased and motion-sensitive datasets separately. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Project temporal tubelets into embedding coordinates. 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: Reproduce a specified ViViT variant rather than treating all factorization choices as interchangeable. R: Bridge Python inference or port the selected attention layout to R torch; validate tubelet flattening with a small deterministic tensor.

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 — Project temporal tubelets into embedding coordinates.

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()
frames = np.arange(8.,dtype=float).reshape(4,2)
tubelets = frames.reshape(2,4)
projection = np.array([[1.,0.],[0.,1.],[1.,0.],[0.,1.]])/2
print(tubelets@projection)
R

Component demo, not a trained model — Project temporal tubelets into embedding coordinates.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
frames <- matrix(0:7,4,byrow=TRUE)
tubelets <- matrix(as.vector(t(frames)),2,byrow=TRUE)
projection <- matrix(c(1,0,0,1,1,0,0,1),4,byrow=TRUE)/2
print(tubelets%*%projection)

Sources

From the CodeSplash reference, entry VID011.