Skip to content

Video understanding, tracking, generation, and world models · Temporal segmentation · VID016 · Architecture

Multi-Stage Temporal Convolutional Network (MS-TCN)

Assigns an action label to every video time step and refines predictions through several temporal-convolution stages.

Runs as a notebook Complete calculation CodeSplash's run and the reference's record

In CodeSplash

No method yet, but the reference's example runs here as a notebook.

Do it in CodeSplash Open the reference's example as a Python or R notebook.

Availability
Runs as a notebook
Code example
Complete calculation
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

Assigns an action label to every video time step and refines predictions through several temporal-convolution stages. It addresses over-segmentation, where a plausible frame classifier produces many short, spurious action fragments.

Question / objective

Estimate a temporally coherent label for every time step and recover complete action segments. This is a learning or inference objective, not a test of a statistical null hypothesis.

Method type and supervision

architecture · Temporal segmentation. Supervised temporal annotations, often on features from a separately pretrained encoder.

Architecture / computational structure

Stack of dilated temporal convolution stages that refine framewise action probabilities.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. Over-smoothing can erase genuine short actions. Many implementations consume precomputed features; their extraction and sampling are part of the method and can leak future context.

Formula / computational definition

L=LCE+λ∑t,cmin⁡((log⁡pt,c−log⁡pt−1,c)2,τ2)L=L_{CE}+\lambda\sum_{t,c}\min((\log p_{t,c}-\log p_{t-1,c})^2,\tau^2) expresses frame supervision plus truncated temporal smoothing; pt,cp_{t,c} is class probability and τ\tau limits the penalty.

Parameters and notation

Learned/estimated quantities: Temporal convolution/attention weights and class-head coefficients are learned; label vocabulary and annotation policy are supplied. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Stage count, dilation schedule, feature stride, smoothing weight and truncation threshold control refinement.

Fitting, fine-tuning, and adaptation

Freeze the feature extractor and fit segmentation stages, then consider joint adaptation. Tune smoothing on segment metrics; greater smoothing can destroy short events. 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 frame accuracy, segmental edit score and segment F1 at several temporal-IoU thresholds, not frame accuracy alone.

Example application

Segment a cooking recording into ordered preparation actions.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Report frame accuracy, segmental edit score and segment F1 at several temporal-IoU thresholds, not frame accuracy alone. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Compute truncated temporal log-probability smoothing. 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' yabufarha/ms-tcn code or a small dilated Conv1d refinement stack. R: Compute segment metrics directly in R; bridge feature extraction and the network, or port the Conv1d stages to R torch.

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

Complete calculation — Compute truncated temporal log-probability smoothing.

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()
p = np.array([[.8,.2],[.75,.25],[.2,.8]])
tau = 0.5
delta = np.diff(np.log(p),axis=0)
smooth = np.minimum(delta**2,tau**2).mean()
print("temporal penalty",smooth)
R

Complete calculation — Compute truncated temporal log-probability smoothing.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
p <- matrix(c(.8,.2,.75,.25,.2,.8),3,byrow=TRUE)
tau <- .5
delta <- log(p[-1,])-log(p[-nrow(p),])
print(mean(pmin(delta^2,tau^2)))

Sources

From the CodeSplash reference, entry VID016.