Video understanding, tracking, generation, and world models · Action recognition · VID012 · Architecture
Multiscale Vision Transformers (MViT)
Builds a hierarchical video representation by reducing token resolution while increasing channel capacity. Pooling inside attention creates multiple scales, making long space-time inputs more manageable than a…
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
Builds a hierarchical video representation by reducing token resolution while increasing channel capacity. Pooling inside attention creates multiple scales, making long space-time inputs more manageable than a fixed-resolution transformer.
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
Hierarchical transformer with pooled queries/keys/values and increasing channel capacity.
Assumptions
Inputs must satisfy the temporal, modality and annotation protocol described below. Early pooling may remove brief or small events. Savings depend on where pooling occurs and do not make arbitrary long-video inference free.
Formula / computational definition
, where pool query, key and value tokens. Stages change resolution and feature width; supervised heads use their task loss.
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: Pooling strides, stage depths, channel expansion, input frame count and position treatment govern the hierarchy.
Fitting, fine-tuning, and adaptation
Tune the output head and upper stages first; unfreeze lower stages if small-object cues change. Changing pooling strides generally requires more than swapping a head. 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 recognition accuracy and memory at several clip lengths; inspect performance on small objects and rapid motion.
Example application
Produce efficient multiscale features for video understanding.
Interpretation / pitfalls
Watch out
An optimized training objective or a favorable example does not establish generalization. Report recognition accuracy and memory at several clip lengths; inspect performance on small objects and rapid motion. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.
Python and R code examples
Component: Pool attention keys and values to reduce token count. 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 authors' SlowFast implementation or explicitly reproduce pooling-attention shapes. R: A reticulate wrapper preserves the Python implementation; R can compare multiscale features and downstream classifiers without retraining the entire backbone.
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 — Pool attention keys and values to reduce token count.
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()
x = np.arange(8.,dtype=float).reshape(4,2)/8
pooled = x.reshape(2,2,2).mean(axis=1)
scores = x@pooled.T/np.sqrt(2)
weights = np.vstack([softmax(row) for row in scores])
print(weights@pooled, "attention shape", weights.shape)
Component demo, not a trained model — Pool attention keys and values to reduce token count.
Shared setup for this chapter
softmax <- function(x) {
e <- exp(x - max(x))
e / sum(e)
}
x <- matrix(0:7,4,byrow=TRUE)/8
pooled <- rbind(colMeans(x[1:2,]),colMeans(x[3:4,]))
scores <- x%*%t(pooled)/sqrt(2)
weights <- t(apply(scores,1,softmax))
print(weights%*%pooled); print(dim(weights))
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry VID012.