LLGA · Course notes

Advanced Deep Learning

CSC_52087_EP · Year 1 · Period 2

Contents

Introduction and overview

Module Advanced Deep Learning
Code CSC_52087_EP
Team and volume Instructors (“Responsables” on the 2026–2027 sheet and on the track page): Johannes Lutzeyer, Xi Wang & Ye Zhu (École Polytechnique), Ye Zhu being the head of the 2026–2027 occurrence; the detailed programme also assigns the self-supervised learning sessions to “VK” — presumably Vicky Kalogeiton, who is not listed among the responsables · 38.25 h (the sheet’s breakdown: 18 h of lectures + 20.25 h of exercise sessions; it has no separate “heures en présentiel” line) · 4.5 ECTS (value of neighboring MScT tracks; the sheet does not publish a value for the LLGA track) · a reading seminar: each chapter takes apart a pivotal paper — ViT, ConvNeXt, mixture of experts, contrastive and masked self-supervision, efficient architectures, training at scale — down to the experimental protocol that underpins it, and the official themes (symmetry, robustness, neural fields, analysis-by-synthesis, amortized inference, sampling, physics) get their own sections, with replication projects.
Official sheet (SynapseS 2026-2027) Official title: “Apprentissage profond avancé” (programme d’approfondissement, computer science) · period: X-3A-P2, from 04/01/2027 to 19/03/2027 · language: English · official assessment, stated in the description: “a combination of homework, quizzes and team projects”, “more details later” (numerical grade out of 20; the assessment section of the sheet for the LLGA track is empty) · prerequisites: not displayed · CSC_52087_EP course sheet
Status in the program P2 OptionOutside recommended track

Audience: an engineer who already runs a ViT or a ResNet and wants to read — and reproduce — the pivotal papers. Empirical first: each topic starts from a result that does not hold up, such as a fine-tuning gain from ImageNet to a business domain that turns into a loss when the batch size changes, or a contrastive pre-training that “cheats” through a leak in the augmentations; only then do we name the tools that explain it: experimental protocol, ablations, the architectures and objectives themselves.

The module is a reading seminar on ViT, ConvNeXt, self-supervision, mixtures of experts and large-scale training.

What you will be able to do

Official objectives and syllabus (2026-2027 catalog)

According to the CSC_52087_EP — “Apprentissage profond avancé” sheet: the official objective is to initiate students into the advanced principles of deep learning — mathematical foundations, architecture design and practical applications.

The description stresses that the field moves at a very fast pace, with new techniques and architectures appearing constantly, and that future practitioners must keep up with the latest advances; the assessment combines homework, quizzes and team projects; the language is English.

The keywords are deep learning, transformers, computer vision and symmetry in deep learning. The detailed programme lists nine themes, with the initials of the instructor in charge; the table maps each of them, in the sheet’s order, to the section that teaches it.

Official theme (SynapseS detailed programme, in order) Section of the course
1. Symmetry in Deep Learning Representations (JL) 4.4 — equivariance and invariance (definition 4.3), permutation equivariance of attention (prop. 4.4), weight-space symmetries and representation comparison (example 4.5); research: 11.2
2. Robustness in Deep Learning (JL) 4.5 — threat models, FGSM and PGD, adversarial training (definition 4.6), Lipschitz certificate (prop. 4.7), example 4.8, natural shifts and fair comparisons
2–3. Self-Supervised Learning (VK) ch. 7 — contrastive (SimCLR, MoCo, BYOL, CLIP) and ch. 8 — masking (MAE, BEiT, DINOv2)
4. Neural Fields (XW) 10.1 — coordinate networks, spectral bias, Fourier features, NeRF encoding and volume rendering (definition 10.1, example 10.2)
5. Differentiability in Deep Learning & Analysis-by-Synthesis (XW) 10.2 — inverse problems through differentiable renderers, relaxations and straight-through (prop. 10.3), reparameterization vs score function (example 10.4)
6. Amortized Inference (XW) 10.3 — amortization and amortization gap (definition 10.5), the exact linear Gaussian case (example 10.6)
7. Efficient Deep Learning through Distillation (YZ) ch. 3 — efficient architectures and knowledge distillation (3.2), DeiT token distillation (4.2), self-distillation in DINOv2 (8.2)
8. Rethinking the Role of Sampling in Modern Deep Learning (YZ) 10.4 — importance sampling of training data (prop. 10.7), guidance and DDIM sampling (example 10.8); data curation (8.2)
9. Deep Learning and Physics (YZ) 10.5 — physics-informed networks (definition 10.9, example 10.10), emulators, diffusion from thermodynamics; research: 11.3
Keywords: transformers, computer vision ch. 0 — refresher on transformers, ch. 4 — ViT, DeiT, Swin, ch. 5 — ConvNeXt
Objectives: mathematical foundations, architecture design, applications proofs in ch. 3, 4, 6, 7, 9, 10; architectures in ch. 3–6; replication project in ch. 2

The sheet names the themes only, so the content of each section is our reading of its title; the 2026–2027 instructors may treat a theme from another angle. Complement to the official programme — the seminar chapters on the experimental protocol (ch. 1), the replication project (ch. 2), ConvNeXt (ch. 5), mixture of experts (ch. 6) and training at scale (ch. 9) do not appear in the published themes; they are the method and the background that the reading of the themed papers relies on.

Where this course fits in the program

An option of period 2 of M1, outside the recommended track. Official prerequisites: not communicated (the “Prerequisites” tab of the SynapseS sheet is empty); in practice, the official description addresses students already initiated into deep learning. The foundation — backpropagation, CNNs, attention, training in practice — comes from the P1 Deep Learning module, whose necessary elements (transformers, optimization, normalization) are reactivated in chapter 0.

Downstream, this module directly prepares Advanced Topics in Large Language Models (M2), which extends the critical reading of papers on the LLM side, and above all the research track of the master’s program: the seminar format and the replication project are its methodical training. Chapter 10 (neural fields, analysis-by-synthesis, sampling, physics) connects to the Image Synthesis and Multimodal Generative AI modules of the same period.

Course outline

Session plan

38.25 h in class = 9 sessions of 4.25 h. The volume is the one of the SynapseS 2026–2027 sheet (38.25 h: 18 h of lectures and 20.25 h of exercise sessions), which we read as nine weeks of a 2 h lecture followed by a 2.25 h exercise session.

The sheet’s detailed programme lists nine themes without dates; the plan follows their order — symmetry (session 3), robustness (4), self-supervision (5–6), neural fields and analysis-by-synthesis (7), amortized inference, sampling and physics (8) — with one exception: distillation, the seventh theme, is taught in session 2 with efficient architectures, because its accounting is used by chapters 4 to 6 and teaching it after the generative themes would make the difficulty go back down.

The seminar’s own chapters (protocol, ConvNeXt, mixture of experts, scale) are interleaved where they are needed, and the split into sessions is our proposal. Since the course is a reading seminar, the research notes of the instructors (ch. 11) are taught in class.

Level 1 = foundations (refresher, protocol, accounting), 2 = the pivotal papers, 3 = research themes and critique; the level never goes down from one session to the next.

Session Hours Level Content Practice
1 4.25 h 1 ch. 0 Refresher; ch. 1 Experimental protocol, seeds, replication Ex. 5
2 4.25 h 1 ch. 2 The reading seminar and the replication project (choice of papers); ch. 3 Depthwise separable convolutions, MobileNet, distillation (official theme 7) Ex. 4
3 4.25 h 2 ch. 4.1–4.4 ViT, DeiT, Swin; symmetry in deep learning representations (official theme 1) Ex. 1, 2
4 4.25 h 2 ch. 4.5 Robustness in deep learning (official theme 2); ch. 5 The ConvNeXt lesson; ch. 6 Mixture of experts and load balancing Ex. 3, 6, 7
5 4.25 h 2 ch. 7 Contrastive self-supervision: SimCLR, MoCo, BYOL (official themes 2–3) Ex. 8
6 4.25 h 2 ch. 8 Masked self-supervision: MAE, BEiT, DINOv2 (official theme 3); ch. 9 Training recipes, scaling laws, µP Ex. 9, 10, 11
7 4.25 h 3 ch. 10.1–10.2 Neural fields; differentiability and analysis-by-synthesis (official themes 4–5) lab: fit a Fourier-feature field to an image; example 10.4 by simulation
8 4.25 h 3 ch. 10.3–10.6 Amortized inference, the role of sampling, deep learning and physics (official themes 6, 8, 9); multimodal and generative bridges Ex. 12
9 4.25 h 3 ch. 11 Research notes: Kalogeiton, Lutzeyer, Zhu, Wang; project defenses presentations of the replication projects

Self-study, outside the 38.25 h: no chapter is left to self-study, since the seminar reads every chapter in class; the replication project is carried out between sessions.

How to study this module

The module in the LLGA master’s program This seminar installs the experimental culture that runs through the entire master’s program: the scaling laws and attention studied here reappear at the heart of the M2 LLMs, and the method — read, criticize, replicate — is exactly what a research internship, a PhD or a research engineer position requires. It is the natural bridge between the M1 deep learning and the research that the LLGA master’s program aims to foster.

0. Refresher: transformers, optimization, normalization

Recall — taught in the P1 Deep Learning module, not redone here

  • Backpropagation: chain rule applied to the computation graph; automatic differentiation (autograd) — DL ch. 2;
  • Optimizers: SGD with momentum, Adam/AdamW (m_t, v_t, bias corrections), warm-up and schedules — DL ch. 3.2–3.4;
  • Normalization: batch norm (batch statistics) vs layer norm (per example, independent of the batch) — DL ch. 3.5; residual connections;
  • Attention: \mathrm{softmax}(QK^\top / \sqrt{d_k}) V, multi-head, positional encoding, the pre-norm block, its costs and the ViT — DL ch. 6; the NLP module applies it to text, the M2 LLMs module at scale;
  • Transfer learning: pre-training + fine-tuning, classification heads — DL ch. 7.

If one of these lines is shaky, reread the linked section before session 1: the seminar uses them without re-deriving them.

Module format: a reading seminar. Each chapter centers on a pivotal paper that we read in full: motivation, method, experiment — and we critique the protocols (datasets, seeds, compute budgets) like a reviewer.

The four instructors each intervene on their own ground (chapter 11): vision and video (Kalogeiton), graphs (Lutzeyer), diffusion models (Zhu), multimodal and video generation (Wang). Chapter 1 (the experimental protocol) and chapter 9 (training at scale) equip the final project (chapter 2): replicating a published result within a given compute budget — the acid test of modern deep learning.

Definition 0.1 — Module notation A self-attention layer with h heads over a sequence of n tokens of dimension d (heads of dimension d_k = d / h).

One block = multi-head attention + MLP (expansion factor 4), each preceded by LayerNorm (pre-norm) and bypassed by a residual connection. Let L denote the number of blocks, d_{\mathrm{ff}} = 4d.

Compute is measured in FLOPs (floating-point operations, a multiply-add counting as 2). For a model with N parameters, a forward pass costs about 2N FLOPs per token (the count of example 4.2), and training on D tokens, forward and backward passes together, costs about C \approx 6\,N D \ \text{FLOPs}. Chapter 9 uses the same N, D and C; elsewhere N is redefined locally (patches in ch. 4, batch size in ch. 7).

1. Reproducible research: experimental protocol

A reported gain is only worth the protocol that produced it. This chapter fixes the minimal protocol that every experiment of the seminar must follow, shows how much the random seed alone can move a result, and turns replication into a method.

Definition 1.1 — Minimal experimental protocol Any reported experiment: (1) a precise question; (2) a falsifiable hypothesis; (3) a protocol: fixed and versioned dataset, a single train/val/test split, a main metric declared before the experiment; (4) a baseline retrained under the same conditions; (5) n \geq 3 seeds with mean ± standard deviation; (6) the ablations; (7) the compute budget reported; (8) code (and ideally data) published.

1.1. Seeds matter (really)

Picard (2021) — “torch.manual_seed(3407) is all you need” — trains identical classifiers over 10,000 seeds: the accuracy gap between seeds reaches several points; the choice of seed can flip a ranking of methods.

Bouthillier et al. (2021) generalize: the variance due to seeds (init, data order, augmentations) must be estimated and reported; comparing two means without variability is comparing noise. Tools: Student’s t confidence intervals over n runs; paired tests when the seeds are coupled; correction for multiple testing (see the Refresher in Statistics module for tests, the Machine Learning module for model selection).

Example 1.2 — A “gain” that isn’t one Method A: 79.4% ± 0.6 (5 seeds); baseline B: 78.9% ± 0.5 (5 seeds). The difference of means is 0.5, and the standard deviation of the difference is \approx \sqrt{0.6^2/5 + 0.5^2/5} \approx 0.35 . The statistic is therefore t \approx 1.4, to be compared with t_{0.975}(8) \approx 2.3: not significant.

The right conclusion: “comparable to the baseline”, not “+0.5% state of the art”. In the project (ch. 2), every results table carries mean ± standard deviation and the name of the test used.

1.2. Replication: the module’s method

  1. pick a number: one row, one table of the pivotal paper;
  2. scale down: same task, model ×0.2 (µP, ch. 9, helps transpose the hyperparameters); a budget declarable in GPU-hours;
  3. instrument: experiment tracking (versioned configs + seeds + curves — W&B/tensorboard; determinism of the loaders; no leakage: the test set is looked at only at the end);
  4. report: paper vs replication table ± standard deviation; analyze the gap (data? recipe? hardware?) — that is where one learns.

Note — Leaks and common pitfalls Splitting per image on video data (nearly identical neighbors); normalization computed over the whole set; selecting the best checkpoint on the test set; an implicit “dev set = test set” after 50 config edits; comparison at unequal training budgets (see DeiT vs ViT, ch. 4; ConvNeXt, ch. 5). Each chapter of the module rereads its pivotal paper with this grid: what is the baseline? the seeds? the budget? the metric declared a priori?

2. Projects: read, explain, replicate

The official sheet announces “a combination of homework, quizzes and team projects”, with details to come. We propose to read the team part as a paper presentation and a replication project; this chapter describes both, lists typical replication topics, and states what must be delivered.

2.1. Reading seminar (30 % of the proposed grade)

Each pair takes charge of one pivotal paper among: ViT, DeiT, Swin, ConvNeXt, Switch, SimCLR, MAE, MobileNetV2, EfficientNet, Chinchilla, µP — and presents it in 20 minutes + 10 of discussion: motivation, contribution, decisive experiment, protocol flaws. Grading grid: understanding (5), rendering of the experiments (5), critical eye (5), answering questions (5).

2.2. Replication project (60 % of the proposed grade)

One number, one replication, one budget. Typical topics:

2.3. Deliverables

  1. repository: code (deterministic, fixed seeds), versioned config, training/evaluation scripts;
  2. report (6–8 pages): question, protocol (def. 1.1), paper/replication table with n seeds ± standard deviation, analysis of the gaps, budget (GPU-hours);
  3. defense: 15 minutes, including “the figure of the paper you wish you had seen” — your best addition to the original protocol.

Note — Grading and budget (proposal) Seminar 30% · project 60% · participation 10%, until the instructors publish the official weights. Compute budget capped (team GPU credits); a “small but rigorous” project (5 seeds, intervals, ablation) beats a “big but opaque” one: that is the spirit of the module.

3. Efficient architectures: MobileNet and distillation

Accuracy is not the only constraint: a model must also fit a latency, memory or energy budget. This chapter gives the exact accounting of the convolution that made mobile networks possible, and the distillation technique that transfers what a large network knows to a small one.

3.1. Depthwise separable — the exact accounting

Proposition 3.1 — Cost of a depthwise separable convolution A standard k \times k convolution, d_{\mathrm{in}} \to d_{\mathrm{out}}, over an h \times w map, costs h w k^2 d_{\mathrm{in}} d_{\mathrm{out}} MACs.

Its depthwise decomposition (one k \times k filter per channel; h w k^2 d_{\mathrm{in}} MACs) + pointwise (1 \times 1 mixing the channels; h w d_{\mathrm{in}} d_{\mathrm{out}} MACs) costs h w\, k^2 d_{\mathrm{in}} + h w\, d_{\mathrm{in}} d_{\mathrm{out}}. Divided by the standard cost, this gives 1/d_{\mathrm{out}} + 1/k^2 for any d_{\mathrm{in}}; for d_{\mathrm{in}} = d_{\mathrm{out}} = d, the ratio to the standard conv is

Key result — cost ratio of a separable convolution \frac{k^2 d + d^2}{k^2 d^2} = \frac{1}{d} + \frac{1}{k^2}.

That is, for k = 3, d = 256: \approx 0.12 — a factor ~8 of compute saved for the same receptive field (at the price of reduced per-layer expressiveness).

Proof. Accounting for the decomposition:

  • depthwise — for each of the d_{\mathrm{in}} channels, a k \times k filter slides over h w positions; h w k^2 d_{\mathrm{in}};
  • pointwise — at each position, a d_{\mathrm{in}} \times d_{\mathrm{out}} matrix product over h w positions; h w d_{\mathrm{in}} d_{\mathrm{out}}.

The sum factors as h w d (k^2 + d), to be compared with h w d^2 k^2 — hence the ratio (k^2 + d)/(k^2 d) = 1/d + 1/k^2 . ∎

3.2. Knowledge distillation

Definition 3.2 — Temperature KD (Hinton et al., 2015) With z_t, z_s the logits of the teacher and the student and T the temperature: \mathcal{L}_{\mathrm{KD}} = (1-\lambda)\,\mathrm{CE}(y, z_s) \;+\; \lambda\, T^2\, \mathrm{KL}\big(\mathrm{softmax}(z_t / T)\,\big\|\,\mathrm{softmax}(z_s / T)\big), with \lambda \in [0, 1] and T typically 3–20.

At high temperature, the teacher’s “soft” distribution reveals the structure of the errors (“this cat looks like a lynx, not like a truck”): bit-rich per-class information that the hard (1-of-K) label does not contain; the T^2 factor compensates for the shrinking gradients.

Applications: compression (student = MobileNet, ch. 3.1 — the standard production chain); self-distillation (DeiT, ch. 4; Born-Again Networks); and label-free distillation on massive unlabeled data (Noisy Student, DINOv2). Bridges: quantization/pruning on the deployment side is covered in the Computer Vision (P2) module, chapter 8; distilled LLMs in the M2 Large Language Models module.

3.3. The “efficiency” reading grid

Objective Technique Key metric Pivotal paper
FLOPs ↓ separable convolutions MACs/image MobileNet
FLOPs ↓ (family) compound scaling accuracy vs FLOPs EfficientNet
params ↓ / transfer distillation student/teacher accuracy Hinton KD, DeiT
capacity ≠ compute top-k MoE active params Switch, Mixtral (ch. 6)
hardware latency INT8 quantization ms/image (P99) Jacob et al. — CV P2 module ch. 8

4. Vision Transformers: ViT, DeiT, Swin

This chapter asks how attention, designed for text, can process images, and at what cost. It reads three papers in sequence: ViT, which treats image patches as tokens; DeiT, which shows that the training recipe matters as much as the architecture; and Swin, which brings locality back. It ends with the first two themes of the official programme: the symmetries that architectures build into their representations (4.4) and robustness to perturbations and distribution shifts (4.5).

What breaks Three mistakes recur when comparing architectures: comparing models that did not get the same pre-training data or compute budget, skipping the ablations (so that the gain may come from another ingredient), and scaling up without monitoring training stability (loss spikes).

4.1. ViT — “An Image is Worth 16x16 Words”

The pivotal paper (Dosovitskiy et al., ICLR 2021) transposes the transformer to images with disarming radicality: cut the image into patches and treat them as tokens.

import torch, torch.nn as nn

class ViT(nn.Module):
    def __init__(self, img=224, patch=16, d=768, L=12, heads=12, n_classes=1000):
        super().__init__()
        self.n = (img // patch) ** 2                     # 196 patches
        self.patch = nn.Conv2d(3, d, kernel_size=patch, stride=patch)
        self.cls = nn.Parameter(torch.zeros(1, 1, d))
        self.pos = nn.Parameter(torch.zeros(1, self.n + 1, d))
        layer = nn.TransformerEncoderLayer(
            d, heads, dim_feedforward=4*d, batch_first=True, norm_first=True)
        self.encoder = nn.TransformerEncoder(layer, L)
        self.head = nn.Linear(d, n_classes)

    def forward(self, x):
        p = self.patch(x).flatten(2).transpose(1, 2)     # (B, n, d)
        z = torch.cat([self.cls.expand(p.size(0), -1, -1), p], dim=1)
        z = self.encoder(z + self.pos)
        return self.head(z[:, 0])                        # [class] token

Proposition 4.1 — Complexities: attention vs convolution For an input with n tokens/spatial positions and dimension d (one layer):

Layer FLOPs Params Spatial dependence
Self-attention O(n^2 d) O(d^2) global, dynamic
MLP (d → 4d → d) O(n d^2) O(d^2) none
Conv k \times k O(k^2 n d^2) O(k^2 d^2) local, static

Proof. Attention:

  • QK^\top is an n \times d by d \times n product → 2n^2 d FLOPs;
  • weighting V adds 2 n^2 d;
  • the projections Q, K, V, O cost 4 \times 2nd^2 = 8nd^2 — hence the total \Theta(n^2 d + n d^2).

Conv: each position (n of them) combines k^2 neighbors over d input/output channels → 2 k^2 n d^2.

Two consequences:

  1. for large n, attention costs n^2 — the wall of high-resolution images;
  2. for d \gg n, the projections dominate — identical to the MLP; the ratio depends on n/d, not on a “transformers always more expensive” rule. ∎

Example 4.2 — Counting ViT-B/16 by hand With 224 \times 224 images and 16 \times 16 patches, there are N = 14^2 = 196 patch tokens plus the \texttt{[class]} token: n = 197.

  • Patch projection. It has 16 \times 16 \times 3 \times 768 \approx 0.59M weights.
  • Blocks. Each of the 12 blocks has 4d^2 (attention) + 8d^2 (MLP) = 12d^2 \approx 7.1M parameters. That makes about 85M in total — the 86M announced for ViT-B.
  • Forward pass. It costs about 2 FLOPs per parameter and per token, 2 \times 85\text{M} \times 197 \approx 33.5 \text{ GFLOPs}, plus the attention products 12 \times 4n^2 d \approx 1.4 GFLOPs. The total is about 35 GFLOPs, i.e. the “17.6 GFLOPs” of the papers, which count multiply-adds.
  • Attention share. At this resolution the attention term is only 4\% of the total. With 8 \times 8 patches, n is multiplied by 4 and the attention term by 16 — the quadratic wall of proposition 4.1.

Note — The lesson of the ViT paper’s data ViT without massive pre-training is inferior to ResNet; only from hundreds of millions of images (JFT-300M) onward does it dominate: the transformer trades convolutional inductive bias (locality, translation) for the ability to ingest data. This architecture×data interaction is THE lesson of the paper — and the guiding thread of the module.

4.2. DeiT — training matters as much as the architecture

Touvron et al. (2021) obtain competitive ViTs on ImageNet-1k alone (1.3 M images): strong augmentation (RandAugment, mixup, cutmix), regularization (stochastic depth, tuned weight decay), the AdamW optimizer, and token distillation. A second token \texttt{[dist]} is supervised by the outputs of a convnet teacher (RegNet); the student thereby learns the inductive bias that the convnet provides for free.

Moral: comparing architectures with unequal training recipes is meaningless — we will return to this with ConvNeXt (ch. 5) and the experimental protocol (ch. 1).

4.3. Swin — local attention via shifted windows

To curb the quadratic growth of attention with the number of patches, the Swin Transformer (Liu et al., ICCV 2021) makes three choices:

  1. attention computed within local windows of M \times M patches (cost linear in the number of windows);
  2. each subsequent layer shifts the windows by M/2 — cross-window connections arise from the shift;
  3. progressive patch merging like a convolutional encoder — Swin serves as a dense backbone (detection, segmentation) where ViT was 1 token = 1 class.

ViT (global, data-dependent, quadratic) and Swin (hierarchical, local, linear) embody the two poles that all subsequent architectures negotiate.

4.4. Symmetry in deep learning representations

The three architectures of this chapter differ above all in the symmetries they build in. A convolution commutes with translations; attention, as shown below, commutes with permutations of its tokens, which is why ViT must learn the geometry of the image from its positional embeddings. Symmetry also lives on the weight side: many different parameter vectors compute the same function, and any comparison of learned representations must account for it.

Definition 4.3 — Equivariance and invariance Let a group G act on inputs through a representation \rho_{\mathrm{in}}(g) and on outputs through \rho_{\mathrm{out}}(g). A map f is G-equivariant if f(\rho_{\mathrm{in}}(g)\,x) = \rho_{\mathrm{out}}(g)\,f(x) \quad \text{for all } g \text{ and } x, and G-invariant if \rho_{\mathrm{out}} is trivial: f(\rho_{\mathrm{in}}(g)\,x) = f(x). Convolutions are equivariant to translations (up to borders), graph neural networks and self-attention without positions to permutations of the nodes or tokens, group-equivariant CNNs to rotations; a global pooling turns an equivariant feature map into an invariant prediction.

Proposition 4.4 — Self-attention without positions is permutation-equivariant (proved) Let X \in \mathbb{R}^{n \times d} hold n tokens, let \mathrm{SA}(X) = \mathrm{softmax}\big(XW_Q (XW_K)^\top/\sqrt{d_k}\big)\,XW_V with the softmax applied row by row, and let \Pi be an n \times n permutation matrix, acting on the rows of X (both representations of definition 4.3 are \Pi itself). Then \mathrm{SA}(\Pi X) = \Pi\,\mathrm{SA}(X). The MLP and the LayerNorm act token by token and are equivariant too, so a ViT without positional embeddings sees its image as an unordered bag of patches.

Proof. With Q = XW_Q, K = XW_K, V = XW_V, replacing X by \Pi X replaces Q, K, V \quad \text{by} \quad \Pi Q, \Pi K, \Pi V.

The score matrix S = QK^\top/\sqrt{d_k} is replaced by \Pi S \Pi^\top: its rows and columns are permuted in the same way. A row-wise softmax commutes with permuting the rows, and permuting the entries inside each row permutes the softmax outputs in the same way, so \mathrm{softmax}(\Pi S\Pi^\top) = \Pi\,\mathrm{softmax}(S)\,\Pi^\top . Hence, since \Pi^\top \Pi = I, \mathrm{SA}(\Pi X) = \Pi\,\mathrm{softmax}(S)\,\Pi^\top \Pi V = \Pi\,\mathrm{SA}(X). ∎

Example 4.5 — Weight-space symmetries, and comparing representations A one-hidden-layer ReLU network f(x) = W_2\,\mathrm{ReLU}(W_1 x) of width h computes exactly the same function with the weights (\Pi W_1, W_2\Pi^\top) for any h \times h permutation \Pi (the hidden units are relabelled).

It also does with (DW_1, W_2D^{-1}) for any diagonal D with positive entries, because \mathrm{ReLU}(dz) = d\,\mathrm{ReLU}(z) for d > 0. A width of h = 1\,000 thus gives 1000! \approx 10^{2568} equivalent labelings of the same network.

Two consequences for research practice:

  • neurons of two independently trained networks cannot be compared index by index, so representations are compared with similarity indices that are invariant to such transformations — linear CKA is invariant to orthogonal transformations and isotropic scaling of the features (Kornblith et al. 2019);
  • averaging the weights of two models only makes sense after aligning their hidden units (Ainsworth et al., “Git Re-Basin”, 2023).

Building the right input symmetry into an architecture — the subject of J. Lutzeyer’s graph work (ch. 11.2) — is the other side of the same question.

4.5. Robustness in deep learning

An accuracy measured on an i.i.d. test split says nothing about two failures that matter in deployment: small worst-case perturbations of the input, and natural shifts of the input distribution. Robustness claims about architectures — “transformers are more robust than CNNs” — are a favourite place for the protocol flaws of chapter 1.

Definition 4.6 — Threat model, adversarial and robust accuracy A threat model fixes the allowed perturbations, typically \|\delta\|_\infty \leq \epsilon with \epsilon = 4/255 or 8/255 on images.

The fast gradient sign method (FGSM, Goodfellow et al. 2015) takes the single step \delta = \epsilon\,\mathrm{sign}\big(\nabla_x\ell(h_\theta(x), y)\big); projected gradient descent (PGD, Madry et al. 2018) iterates \delta \leftarrow \Pi_{\|\delta\|_\infty \leq \epsilon}\big(\delta + \alpha\,\mathrm{sign}\,\nabla_\delta\ell(h_\theta(x + \delta), y)\big).

Robust accuracy is the accuracy under the strongest attack tried; adversarial training minimizes \mathbb{E}\max_{\|\delta\| \leq \epsilon}\ell(h_\theta(x + \delta), y), the inner maximum being approximated by PGD.

Proposition 4.7 — A certificate from the margin and the Lipschitz constant (proved) Let z(x) \in \mathbb{R}^K be the logits, L-Lipschitz in \ell_2 (each logit difference is then \sqrt{2}L-Lipschitz), and let m(x) = z_y(x) - \max_{k \neq y} z_k(x) > 0 be the margin of the correct class y. Every perturbation with \|\delta\|_2 < m(x)/(\sqrt{2}L) leaves the prediction unchanged.

Proof. For k \neq y, the map u \mapsto z_y(u) - z_k(u) is the composition of z with the linear form e_y - e_k, of norm \sqrt 2, so it is \sqrt{2}L-Lipschitz. Hence z_y(x + \delta) - z_k(x + \delta) \geq z_y(x) - z_k(x) - \sqrt{2}L\|\delta\|_2 \geq m(x) - \sqrt{2}L\|\delta\|_2 > 0 , so class y stays the largest logit. ∎

Example 4.8 — Why tiny perturbations suffice in high dimension For a linear logit difference w^\top x, the \ell_\infty perturbation \delta = -\epsilon\,\mathrm{sign}(w) lowers it by exactly \epsilon\|w\|_1.

Take a 224 \times 224 \times 3 input (d = 150\,528) with weights of typical size |w_i| \approx 10^{-3} and \epsilon = 1/255. The shift is 150\,528 \times 10^{-3}/255 \approx 0.59 . A change of one grey level per pixel thus moves the score by more than half a unit, because d small contributions add up coherently.

In \ell_2 the same perturbation has norm \epsilon\sqrt{d} \approx 1.5, while proposition 4.7 only certifies radii of order m/L. With the loose product-of-norms bound on L for a deep network, the certified radius is usually far below this, which is why certified and empirical robustness are reported separately.

Reading robustness papers with the chapter 1 grid Three checks:

  1. Attack strength: a defence evaluated only with FGSM, or with PGD at few steps, often breaks under a stronger or adaptive attack; standardized suites such as AutoAttack (Croce & Hein 2020) are the minimum.
  2. Natural shifts: corruptions (ImageNet-C, Hendrycks & Dietterich 2019), renditions, new test sets collected the same way (ImageNet-V2) measure out-of-distribution robustness, which adversarial accuracy does not predict.
  3. Equal recipes: Bai et al. (NeurIPS 2021) found that once CNNs are trained with transformer-style recipes, they are about as robust as transformers to adversarial attacks, while transformers keep an advantage on several out-of-distribution benchmarks — the DeiT and ConvNeXt lesson again (sections 4.2 and ch. 5).

5. Modern convnets: the ConvNeXt lesson

After a decade of “transformers win everywhere”, the ConvNeXt paper (Liu et al., CVPR 2022) asks the reverse question: what are modernized convnets worth under an equal training recipe? Method: start from a ResNet and align it step by step with the ViT choices — each step is ablated and measured:

# Change ImageNet gain
1 modern training (90→300 epochs, AdamW, augmentation, label smoothing…) 76.1 → 78.8 (+2.7 — the largest gain from a single line!)
2 macro-design: blocks per stage (3, 3, 9, 3) as in Swin’s 1:1:3:1, and a “patchify” stem (4×4, stride 4) → 79.5 (+0.7)
3 ResNeXt-ify: 3×3 conv → depthwise, width raised to 96 channels → 80.5 (+1.0)
4 inverted bottleneck (thin→wide→thin) → 80.6 (+0.1)
5 large kernels: depthwise layer moved up, 7×7 → 80.6 (+0.0)
6 micro: GELU, fewer activations and normalizations, LayerNorm instead of BatchNorm, separate downsampling → 82.0 (+1.4)

Paper’s conclusion: the “modernized” convnet (ConvNeXt-T, 82.0) exceeds Swin-T (81.3) at comparable FLOPs and throughput. The methodological lesson is stronger than the result: training (line 1) and scale details matter more than the architecture family — a direct application of the protocol of chapter 1, and a spectacular application of the “one change at a time” protocol.

Note — Depthwise, the missing link Depthwise convolution (one spatial filter per channel, no cross-channel mixing — see MobileNet, ch. 3) is what enables large 7×7 kernels at contained cost: cost O(k^2 n d) instead of O(k^2 n d^2). ConvNeXt borrows it from mobile convnets; the wide receptive field is a reminder that vision does not need global attention to be effective — only a wide range of dependencies.

6. Mixture of Experts (MoE)

A dense network pays for all its parameters on every token. This chapter studies the layer that breaks this link: many expert sub-networks, of which a learned router activates only a few per token, so that capacity can grow without the compute per token growing with it.

Definition 6.1 — Sparse MoE layer A MoE feed-forward layer replaces the single MLP with n_E experts \mathrm{FFN}_1, \dots, \mathrm{FFN}_{n_E} (identical MLPs with distinct parameters) and a routing gate g that computes per-token weights: y = \sum_{i=1}^{n_E} \mathbb{1}[i \in \mathrm{TopK}(g(x), k)]\; g_i(x)\; \mathrm{FFN}_i(x), \qquad g(x) = \mathrm{softmax}(W_g x). Typically k = 1 (Switch) or k = 2 (Mixtral, which renormalizes the k selected weights to sum to 1, as the code below does), and n_E = 8 to 128. The symbol E is kept for the irreducible loss of chapter 9.

Per token, only k experts are executed: total parameters grow with n_E, but FLOPs per token grow as k, not as n_E — capacity and compute are decoupled.

Proposition 6.2 — Capacity/cost decoupling For a MoE layer of dimension d, expansion r = 4, n_E experts, top-k:

  • parameters \approx 2 n_E r d^2;
  • FLOPs per token \approx 4 k r d^2, counting a multiply-add as 2 FLOPs (plus the routing, 2 n_E d, negligible);
  • loading memory \propto n_E, activation memory \propto k.

Proof. An MLP d \to r d \to d has 2 r d^2 parameters and 4 r d^2 FLOPs per token (two matrix products).

With n_E experts, the parameters are multiplied by n_E; the computation executes only the k selected experts — the factor is k.

The routing (a d \times n_E matrix) costs 2 n_E d, below 4krd^2 as soon as n_E < 2krd, which holds by a wide margin in practice. ∎

6.1. Balancing the load

The canonical risk: the gate learns to send everything to the same experts (routing collapse) — the other experts receive no more gradient and die. The historical remedy of Shazeer et al. (2017): noise in the routing + an auxiliary loss. Switch Transformer (Fedus et al., 2022) formalizes the load balancing loss:

Key result — load balancing loss \mathcal{L}_{\mathrm{aux}} = \alpha_{\mathrm{aux}}\, n_E \sum_{i=1}^{n_E} f_i\, P_i, \qquad f_i = \frac{\text{tokens sent to } i}{k \times \text{total tokens}}, \quad P_i = \frac{1}{T}\sum_{t} g_i(x_t).

Here T is the number of tokens in the batch, P_i the average probability assigned to expert i by the gate (differentiable), and f_i the fraction of the routing slots actually sent to it (non-differentiable).

Each token fills k slots, so dividing by k makes the f_i sum to 1; with Switch’s top-1 routing it is the plain token fraction.

Under uniform routing, f_i = P_i = 1/n_E, so \sum_i f_i P_i = 1/n_E and the loss equals \alpha_{\mathrm{aux}} whatever the number of experts. The gradient flows only through the P_i, each weighted by f_i: it lowers the gate probability of the experts that already receive more than their share of tokens, which pushes the routing towards balance.

Added to this are the capacity per expert, k \times (\text{tokens}/n_E) \times a capacity factor — beyond it, tokens “overflow” (passed on to the rest of the network) — and per-expert parallelization (expert parallelism: each device holds experts).

The M2 Large Language Models module states the same layer and the same loss with the same symbols, and its exercise 9 asks for the minimum of the loss: balance is the minimum when f_i = P_i, but not in general (exercise 7 (b) below); this chapter keeps the statements and reads them on vision and character-level models.

import torch, torch.nn as nn, torch.nn.functional as F

class MoE(nn.Module):
    def __init__(self, d=1024, r=4, n_E=8, k=2, alpha_aux=0.01):
        super().__init__()                     # r = expansion factor: hidden width r*d
        self.experts = nn.ModuleList(
            [nn.Sequential(nn.Linear(d, r * d), nn.GELU(), nn.Linear(r * d, d))
             for _ in range(n_E)])
        self.gate = nn.Linear(d, n_E)
        self.k, self.n_E, self.alpha_aux = k, n_E, alpha_aux

    def forward(self, x):                      # x: (T, d), the T tokens of the batch
        logits = self.gate(x)                  # (T, n_E)
        probs = logits.softmax(-1)
        topk_w, topk_i = probs.topk(self.k, dim=-1)
        topk_w = topk_w / topk_w.sum(-1, keepdim=True)
        out = torch.zeros_like(x)
        for e in range(self.n_E):
            mask = (topk_i == e)               # tokens assigned to expert e
            sel = mask.any(-1)
            if sel.any():
                out[sel] += topk_w[sel].masked_fill(~mask[sel], 0).sum(-1, keepdim=True) \
                            * self.experts[e](x[sel])
        f = torch.zeros(self.n_E, device=x.device)   # routed fraction (non-diff.)
        f.scatter_add_(0, topk_i.flatten(),
                       torch.ones(topk_i.numel(), device=x.device))
        f = f / (self.k * x.size(0))           # k slots per token, so sum(f) = 1
        aux = self.alpha_aux * self.n_E * (f * probs.mean(0)).sum()
        return out, aux                           # (output, auxiliary loss)

6.2. Panorama and readings

Example 6.3 — A routing in practice A MoE layer d = 1024, expansion r = 4 (hidden width 4096), n_E = 8, k = 2:

  • parameters 2 \times 8 \times 4 \times 1024^2 \approx 67M per layer;
  • FLOPs per token \approx 4 \times 2 \times 4 \times 1024^2 \approx 34M — twice a dense MLP of the same width, whatever n_E;
  • a 32-layer model stores \approx 2.1B parameters in its MoE layers but activates only \approx 0.54B per token.

Compare with the compute-matched dense model (larger d): the MoE wins on data-abundant tasks, pays in memory and system complexity (all parameters must reside in memory — see ch. 3 for the remedies).

7. Self-supervision I: contrast (SimCLR and its lineage)

Labels are expensive; images are not. This chapter shows how to pre-train a network without any label, by asking it to recognize two transformed views of the same image among many others.

Definition 7.1 — Self-supervised pre-training Manufacture the labels from the data itself (rotations, neighborhoods, paired patches, masking) and pre-train without annotation; the model learns transferable representations (linear probing, fine-tuning). The dominant pattern in vision: two families — contrastive (bring two views of the same content closer, push the others apart — this chapter) and generative/masking (reconstruct what is missing — chapter 8).

7.1. SimCLR — the complete recipe

Example 7.2 — Why the temperature The term \mathrm{sim}/\tau rescales the similarities (into [-1/\tau, 1/\tau]): a small \tau sharpens the softmax — the closest negatives dominate the gradient (“hard” learning); a large \tau flattens it — a uniform gradient over all negatives.

With cosine similarities that are bounded, without \tau the softmax would be too flat to discriminate: \tau is the single parameter that tunes this concentration/uniformity trade-off (see the alignment/uniformity analysis of Wang & Isola, 2020: NT-Xent pushes positives to align and negatives to spread uniformly over the sphere).

7.2. MoCo and BYOL — two decisive variations

CLIP in one paragraph. Two encoders map a batch of N (image, caption) pairs to unit vectors, u_i for the images and v_i for the captions, and the N \times N similarity matrix S_{ij} = u_i^\top v_j / \tau is read as two classification problems. Each image must pick its own caption among the N (softmax over row i), and each caption its own image (softmax over column j); the loss averages the two cross-entropies, and the temperature is learned. The negatives come from the other modality only. Zero-shot classification then scores an image against captions such as “a photo of a dog”. The Multimodal GenAI module (ch. 5) goes further; nothing here depends on it.

Proposition 7.3 — NT-Xent without negatives does not work as is If one removes the denominator (the negatives) in \ell_{i,j}, the loss reduces to -\mathrm{sim}(z_i, z_j)/\tau, minimized by any encoder that maps every image to the same unit vector: collapse is an optimal solution.

Proof. Without negatives, \ell_{i,j} = -\mathrm{sim}(z_i, z_j)/\tau \geq -1/\tau only rewards the intra-pair similarity; the constant encoder z \equiv c achieves \mathrm{sim} = 1 for every pair — global optimum, useless representation. Negatives (SimCLR/MoCo), the asymmetric target (BYOL) or variance terms (VICReg) are three distinct solutions to this identification problem. ∎

def nt_xent(z1, z2, tau=0.5):
    """z1, z2: (N, d) head outputs for the two views; normalized below."""
    import torch
    import torch.nn.functional as F
    z1, z2 = F.normalize(z1, dim=-1), F.normalize(z2, dim=-1)
    z = torch.cat([z1, z2], 0)                      # (2N, d)
    sim = z @ z.t() / tau                           # (2N, 2N)
    N = z1.size(0)
    mask = ~torch.eye(2 * N, dtype=torch.bool, device=z.device)
    sim_i = sim.masked_fill(~mask, float("-inf"))
    target = (torch.arange(2 * N, device=z.device) + N) % (2 * N)   # positive of i
    return F.cross_entropy(sim_i, target)           # softmax over the 2N - 1 other views

8. Self-supervision II: masking (MAE, BEiT, DINOv2)

Contrastive learning needs carefully designed augmentations and many negatives. This chapter presents the other route to label-free pre-training, borrowed from BERT: hide most of the image and train the network to fill in what is missing.

8.1. Masked Autoencoders (MAE)

He et al. (CVPR 2022): mask 75% of the patches and reconstruct the missing pixels. Two asymmetries make the whole design:

Definition 8.1 — MAE loss With \Omega the set of masked patches and x_i the targets (normalized pixels: per-patch normalization by mean/variance; variant: targets from a VQ-VAE — BEiT): \mathcal{L}_{\mathrm{MAE}} = \frac{1}{|\Omega|} \sum_{i \in \Omega} \| \hat x_i - x_i \|^2, averaged over the masked patches only. Per-patch normalization recenters the task on structure (relative to the patch) rather than on absolute luminance.

Example 8.2 — Why 75% and not 15% (BERT) Images have enormous spatial redundancy: masking 15% of an image can be solved by local interpolation (in the filter sense, not the network sense) — the encoder learns nothing semantic. At 75%, interpolation no longer suffices: reconstructing a half-masked face requires having understood “face”. Text, on the other hand, is non-redundant: 15% is enough to force syntax and semantics.

The same idea — “mask until the task becomes semantic” — governs the rates in audio (wav2vec 2.0 masks about half of the time steps) and in video (VideoMAE masks 90% or more) — and we will find this principle again in the Multimodal GenAI module, chapter 3, on the diffusion side (how much noise is needed for denoising to be difficult?).

8.2. BEiT and DINOv2

Definition 8.3 — The DINO self-distillation objective (Caron et al. 2021), used by DINOv2 A student h_\theta and a teacher h_\xi share one architecture, ending in a head with K outputs (65 536 in DINO). For two views x_1, x_2 of an image, the teacher’s output is centered by a vector c and sharpened by a low temperature T_{\mathrm{te}}: p = \mathrm{softmax}\big((h_\xi(x_1) - c)/T_{\mathrm{te}}\big). The student matches it from the other view, at a higher temperature T_{\mathrm{st}}: \mathcal{L}_{\mathrm{DINO}} = -\sum_{k=1}^{K} p_k \log \mathrm{softmax}\big(h_\theta(x_2)/T_{\mathrm{st}}\big)_k . No gradient reaches the teacher: its weights are a moving average of the student’s, \xi \leftarrow m\,\xi + (1 - m)\,\theta, and c is a moving average of the teacher’s outputs over the batches.

Centering alone would push the target towards the uniform distribution, and sharpening alone (T_{\mathrm{te}} \approx 0.04 against T_{\mathrm{st}} = 0.1) towards a one-hot one; together they avoid both collapses, two forms of the constant encoder of proposition 7.3, without any negative. The views are two large crops, seen by both networks, and several small crops seen by the student only (multi-crop).

DINOv2 adds three ingredients to this loss: an iBOT term, the same cross-entropy applied to the patch tokens that are masked in the student’s input (the masking of section 8.1, inside a distillation); a KoLeo regularizer that spreads the features of a batch over the sphere; and Sinkhorn–Knopp centering of the teacher in place of the moving average.

Family Signal Strengths Weaknesses
Contrastive (SimCLR, MoCo) view matching highly discriminative representations sensitive to augmentations; negatives to manage
Masking (MAE, BEiT) reconstruction of the missing little a priori; scalable; strong in dense tasks (seg.) weaker in “global” linear probing
Self-distillation (DINO, DINOv2) self-improved teacher-target best of both worlds, curated data complex recipes

9. Training at scale: recipes and scaling laws

Large training runs cannot be tuned by trial and error. This chapter collects the recipe that makes them stable, the empirical laws that predict their loss from the model size and the data, and a parametrization that lets hyperparameters found on a small model transfer to a large one.

9.1. The modern recipe

9.2. Scaling laws — Kaplan then Chinchilla

Definition 9.1 — Power law for the loss Kaplan et al. (2020) showed that the test loss of transformers falls as a power law of the number of parameters N and of training tokens D, over several orders of magnitude, with small exponents (about 0.076 in N and 0.095 in D) and no irreducible term. Hoffmann et al. (2022, “Chinchilla”) fitted the joint dependence in the additive form

Key result — scaling law (Hoffmann et al. 2022) L(N, D) \approx E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}},

with an irreducible loss E > 0 (the entropy of the data, which no model removes) and fitted exponents \alpha \approx 0.34, \beta \approx 0.28 — the most cited graph of modern deep learning.

Kaplan’s own joint law has another form, L(N, D) = \Big[\big(N_c/N\big)^{\alpha_N/\alpha_D} + D_c/D\Big]^{\alpha_D}, and led to the opposite advice: at fixed compute, grow the model much faster than the data (N^\star \propto C^{0.73}). Chinchilla’s refit, with a learning-rate schedule matched to the length of each run, moved the allocation to roughly equal parts — theorem 9.2.

Theorem 9.2 — Compute-optimal optimum (symmetric case, Chinchilla sketch) With the compute budget C \approx 6ND fixed, minimizing L leads to a point (N^\star, D^\star) where N^\star and D^\star both grow as \sqrt{C} — models and data must be enlarged together, in roughly equal parts (tokens per parameter ≈ constant, ~20 in the paper).

Proof. (Case \alpha = \beta, as a sketch; the general case is an exercise.) We minimize A/N^\alpha + B/D^\beta under the constraint ND = C/6. Set \mu = C/6 and D = \mu/N; using \beta = \alpha, F(N) = A N^{-\alpha} + B N^{\alpha}/\mu^{\alpha}. Then F'(N) = -\alpha A N^{-\alpha-1} + \alpha B N^{\alpha-1}/\mu^{\alpha} = 0 gives N^{2\alpha} = A \mu^{\alpha} / B, that is N^\star = (A/B)^{1/(2\alpha)} \mu^{1/2}, proportional to \mu^{1/2} \propto C^{1/2}, and D^\star = \mu / N^\star \propto \mu^{1/2} \propto C^{1/2}.

In the general case (exercise 10) the exponents become N^\star \propto C^{\beta/(\alpha+\beta)}, \qquad D^\star \propto C^{\alpha/(\alpha+\beta)}. Chinchilla (Hoffmann et al., 2022) estimates \alpha \approx 0.34, \beta \approx 0.28 by regression, i.e. exponents 0.45 and 0.55, close to the symmetric 0.5 — revealing that GPT-3 and the like were “too big for their data”. At equal budget, Chinchilla (70B parameters, 1.4T tokens) beats Gopher (280B parameters, 300B tokens). ∎

The general derivation is theorem 3.1 of the M2 Large Language Models module, with the same symbols; this module keeps the symmetric sketch and the replication angle (ch. 2.2).

9.3. MuP — transferring hyperparameters (sketch)

The practical problem: the scaling law applies to losses, but every model size requires its own hyperparameters (lr above all) — and one cannot grid-search a 70B model.

µP (muParametrization) (Yang & Hu — Tensor Programs IV–V): a rule for parametrizing the initializations and the lr by width (hidden layers; multipliers in d^{-1/2}, d^{-1}…) under which the training behavior becomes independent of width. One can then tune the hyperparameters on a small model and transfer them with zero trials to the large one (muTransfer) — spectacular savings on very large runs. We demonstrate the idea on an MLP of variable width (exercise 11) and refer to the paper for the full program.

The rule for Adam, the optimizer of section 9.1, fits in one table (Yang et al., table 3). Here n_{\mathrm{in}} is the fan-in of the weight matrix, and SP is the standard parametrization:

Weights Init. variance, SP Init. variance, µP Adam lr, SP Adam lr, µP
input layer, and all biases 1/n_{\mathrm{in}} 1/n_{\mathrm{in}} \eta \eta
hidden (width → width) 1/n_{\mathrm{in}} 1/n_{\mathrm{in}} \eta \eta/n_{\mathrm{in}}
output (width → classes) 1/n_{\mathrm{in}} 1/n_{\mathrm{in}}^2 \eta \eta/n_{\mathrm{in}}

The factors are read relative to a base width at which \eta was tuned. Under SP, the updates of the hidden and output layers grow with the width, so the best \eta drifts as the model widens; under µP every layer’s update stays of order one, so the best \eta found on a narrow proxy stays close to the best on the wide model. In transformers, µP also replaces the attention scaling 1/\sqrt{d_k} by 1/d_k.

Note — Reading a recipe A serious training paper publishes: the exact configuration (lr, schedule, wd, batch, precision), seeds and variances, the FLOPs budget, hardware and duration, and the ablation justifying every ingredient. It is this level of detail that enables replication — the subject of chapters 1 and 2.

10. Beyond recognition: neural fields, inference, sampling and physics

The previous chapters trained networks to recognize. The second half of the official programme turns to networks that represent signals and scenes, that are inverted to explain observations, that sample, and that meet physics. This chapter gives the founding objects of each theme, with one worked example each; the instructors’ own research on them is in chapter 11, and section 10.6 points to the modules where they are developed.

10.1. Neural fields

Definition 10.1 — Neural field A neural field is a network f_\theta\colon \mathbb{R}^k \to \mathbb{R}^m that maps coordinates to values: pixel position to colour (k = 2, m = 3), 3D point to signed distance to a surface (k = 3, m = 1), 3D point and viewing direction to density and colour (NeRF).

The signal is stored in the weights rather than on a grid: the representation is continuous, can be queried at any resolution, and is differentiable with respect to both the coordinates and the parameters. Fitting a field to one signal minimizes \sum_j \|f_\theta(x_j) - s_j\|^2 over samples (x_j, s_j) of that signal.

A plain MLP on raw coordinates learns the low frequencies of a signal first and fits fine detail very slowly (the spectral bias of networks). Two remedies are standard: map the coordinates through sinusoids before the MLP (Fourier features, Tancik et al. 2020; the positional encoding of NeRF, Mildenhall et al. 2020), or use sine activations throughout (SIREN, Sitzmann et al. 2020).

Volume rendering in five lines (no Image Synthesis prerequisite)

  • A camera ray crosses a medium of density \sigma \geq 0: light is stopped in a short segment of length \delta with probability about \sigma\delta.
  • Cut the ray into samples i = 1, 2, \dots with spacings \delta_i, densities \sigma_i and colours c_i. Segment i has opacity 1 - e^{-\sigma_i\delta_i}.
  • The transmittance T_i = \exp(-\sum_{j<i}\sigma_j\delta_j) is the probability that the ray reaches sample i without being stopped before.
  • The weight w_i = T_i\,(1 - e^{-\sigma_i\delta_i}) is the probability that the ray stops in segment i; the weights sum to at most 1, the rest going to the background.
  • The pixel colour is the expected colour at the stopping point, \hat C = \sum_i w_i c_i, a differentiable function of every \sigma_i and c_i.

Example 10.2 — The NeRF positional encoding, counted NeRF encodes each coordinate p \in [-1, 1] as \gamma(p) = \big(\sin(2^0\pi p), \cos(2^0\pi p), \dots, \sin(2^{L-1}\pi p), \cos(2^{L-1}\pi p)\big) with L = 10 for positions. The highest band \sin(2^9\pi p) has period 2/2^9 = 1/256, so the encoded input can vary at the scale of about 1/512 of the unit interval, the detail of a 1\,000-pixel image across the scene.

A 3D point becomes 3 + 3 \times 2 \times 10 = 63 numbers (the raw coordinates are kept). The image of a ray is then produced by the volume rendering sum \hat C = \sum_i T_i\,(1 - e^{-\sigma_i\delta_i})\,c_i \quad \text{with} \quad T_i = \exp(-\sum_{j<i}\sigma_j\delta_j), where (\sigma_i, c_i) are the density and colour predicted at the samples along the ray and \delta_i their spacing — a differentiable function of \theta, which is what makes the next section possible. The Image Synthesis module (ch. 10) derives this formula from the physics of light transport; the box above is all this course needs.

10.2. Differentiability in deep learning and analysis-by-synthesis

Analysis-by-synthesis explains an observation y by searching for the parameters z of a generative process R (a renderer, a simulator, a decoder) that reproduce it: \min_z \|R(z) - y\|^2 + \lambda\,\Omega(z). When R is differentiable, this is solved by gradient descent through R: fitting a NeRF to photographs (ch. 10.1) is analysis-by-synthesis with z = \theta; recovering the pose, shape or lighting of an object by differentiable rendering is another instance. The difficulty is that many useful operations are not differentiable, or have zero gradient almost everywhere.

Proposition 10.3 — Hard decisions have no useful gradient; relaxations restore one Let a pixel be covered by a shape whose edge sits at signed distance t from the pixel centre, with coverage c(t) = \mathbb{1}[t > 0]. Then c'(t) = 0 for every t \neq 0: gradient descent on the edge position receives no signal, whatever the image error.

The smoothed coverage c_s(t) = 1/(1 + e^{-t/s}) has derivative c_s'(0) = 1/(4s) and non-zero derivatives everywhere, at the price of a bias of order s; this is the principle of soft rasterizers (Liu et al. 2019).

The same reasoning applies to \arg\max (replaced by a softmax at temperature s) and to discrete sampling (replaced by the Gumbel-softmax relaxation). The straight-through estimator keeps the hard operation in the forward pass and uses the gradient of a smooth surrogate in the backward pass.

Example 10.4 — Two gradient estimators for an expectation When the quantity to optimize is an expectation — a stochastic renderer, a sampled latent — J(\mu) = \mathbb{E}_{z \sim \mathcal{N}(\mu, 1)}[g(z)], there are two unbiased estimators of J'(\mu):

  • Reparameterization: write z = \mu + \varepsilon with \varepsilon \sim \mathcal{N}(0, 1) and differentiate inside, g'(\mu + \varepsilon); it needs g differentiable.
  • Score function (REINFORCE): g(z)\,\partial_\mu\log p_\mu(z) = g(z)(z - \mu); it only needs to evaluate g.

For g(z) = z^2, J(\mu) = \mu^2 + 1 and J'(\mu) = 2\mu. Both estimators have mean 2\mu: \mathbb{E}[2(\mu + \varepsilon)] = 2\mu, \qquad \mathbb{E}[(\mu + \varepsilon)^2\varepsilon] = \mathbb{E}[\mu^2\varepsilon + 2\mu\varepsilon^2 + \varepsilon^3] = 2\mu. At \mu = 1 their variances are 4 for the reparameterized one and \mathbb{E}[(1 + \varepsilon)^4\varepsilon^2] - 4 = 1 + 18 + 15 - 4 = 30 for the score function. When the process is differentiable, differentiating through it is far more sample-efficient.

10.3. Amortized inference

Analysis-by-synthesis solves one optimization problem per observation. When the same kind of inference is needed for millions of observations, it pays to learn the map from observation to answer once, and then answer with a single forward pass: this is amortized inference.

Definition 10.5 — Amortized inference and the amortization gap For a latent-variable model p(x, z), per-instance variational inference fits, for each x, the distribution q_x^\star that maximizes the ELBO of x within a family \mathcal{Q}. Amortized inference trains one encoder x \mapsto q_{\phi(x)} \in \mathcal{Q} on the whole dataset, as in the VAE.

The gap \log p(x) - \mathrm{ELBO}(q_{\phi(x)}) splits into an approximation gap \log p(x) - \mathrm{ELBO}(q_x^\star), due to the family \mathcal{Q}, and an amortization gap \mathrm{ELBO}(q_x^\star) - \mathrm{ELBO}(q_{\phi(x)}) \geq 0, due to sharing one encoder across all x (Cremer, Li & Duvenaud 2018).

Beyond VAEs, the same idea gives neural posterior estimation for simulators in science and feed-forward 3D reconstruction, which predicts a scene in one pass instead of fitting a field per scene.

Example 10.6 — A linear Gaussian model, where amortization is exact Let z \sim \mathcal{N}(0, 1) and x = az + \eta with \eta \sim \mathcal{N}(0, s^2). The posterior is Gaussian: its precision is 1 + a^2/s^2, so its variance is v = s^2/(a^2 + s^2), and its mean is v \cdot ax/s^2 = \frac{a}{a^2 + s^2}\,x . For a = 2, s = 1: p(z \mid x) = \mathcal{N}(0.4x, 0.2). A linear encoder \mu_\phi(x) = \phi x with constant variance contains the exact posterior for every x (\phi = 0.4, variance 0.2), so the amortization gap is zero once it is trained: one multiplication replaces one optimization per observation.

With a non-linear decoder, the optimal posterior parameters are a complicated function of x, the encoder only approximates it, and the gap becomes positive — which motivates semi-amortized schemes that refine the encoder’s output with a few per-instance gradient steps (Kim et al. 2018).

10.4. Rethinking the role of sampling in modern deep learning

Sampling enters deep learning at three levels, and each has become a design choice rather than a default: which training data are sampled (mini-batches, hard negatives in contrastive learning, curated corpora such as LVD-142M in ch. 8.2); how a generative model is sampled (temperature, guidance, number of diffusion steps); and how many samples are drawn and selected at test time. The first level has a clean optimization answer.

Recall — DDPM in ten lines (Deep Learning P1, section 9.4)

  • A schedule \beta_1 < \dots < \beta_T sets \alpha_t = 1 - \beta_t and \bar\alpha_t = \prod_{s \leq t}\alpha_s; step t = 0 is the data, and x_T is almost pure noise.
  • The forward (noising) process has a closed form at every step: x_t = \sqrt{\bar\alpha_t}\,x_0 + \sqrt{1 - \bar\alpha_t}\,\varepsilon, \qquad \varepsilon \sim \mathcal{N}(0, I).
  • A network \varepsilon_\theta(x_t, t, c) is trained to predict the noise \varepsilon by a squared-error regression, a reweighted ELBO; the condition c is replaced by the empty condition \varnothing on a fraction of the examples, so one network learns both the conditional and the unconditional model.
  • Sampling starts from x_T \sim \mathcal{N}(0, I) and denoises step by step. From the predicted noise, the clean image is estimated as \hat x_0 = \big(x_t - \sqrt{1 - \bar\alpha_t}\,\varepsilon_\theta\big)/\sqrt{\bar\alpha_t}.

Proposition 10.7 — Importance sampling of training examples (proved) Let F = \frac1n\sum_{i=1}^{n} f_i. Drawing an index i with probability q_i > 0 and using g = \nabla f_i/(nq_i) gives an unbiased gradient, \mathbb{E}[g] = \nabla F, whose second moment \mathbb{E}\|g\|^2 = \frac{1}{n^2}\sum_i \|\nabla f_i\|^2/q_i is minimized by q_i \propto \|\nabla f_i\|, with minimum \big(\frac1n\sum_i\|\nabla f_i\|\big)^2.

Proof. \mathbb{E}[g] = \sum_i q_i\,\nabla f_i/(nq_i) = \nabla F, and \mathbb{E}\|g\|^2 = \sum_i q_i\|\nabla f_i\|^2/(n^2q_i^2). By Cauchy–Schwarz, \big(\sum_i\|\nabla f_i\|\big)^2 = \big(\sum_i \frac{\|\nabla f_i\|}{\sqrt{q_i}}\sqrt{q_i}\big)^2 \leq \sum_i\frac{\|\nabla f_i\|^2}{q_i}\sum_i q_i , and \sum_i q_i = 1; equality holds when \sqrt{q_i} is proportional to \|\nabla f_i\|/\sqrt{q_i}, i.e. q_i \propto \|\nabla f_i\|. ∎

Example 10.8 — Sampling in data and in generation Data. Two examples with scalar gradients 1 and 9, so \nabla F = 5.

  • Uniform sampling (q_i = \tfrac12, so nq_i = 1) gives the values 1 and 9, of variance \tfrac12(1 - 5)^2 + \tfrac12(9 - 5)^2 = 16 ;
  • sampling with q = (0.1, 0.9) gives 1/(2 \times 0.1) = 5 and 9/(2 \times 0.9) = 5, of variance 0.

Gradient norms are unknown before computing them, so practical schemes use cheap proxies (the loss, a stale norm) and must reweight to stay unbiased (Katharopoulos & Fleuret 2018).

Generation. For a diffusion model (recall box above), classifier-free guidance (Ho & Salimans 2022) samples with \tilde\varepsilon = \varepsilon_\theta(x_t, t, \varnothing) + w\,\big(\varepsilon_\theta(x_t, t, c) - \varepsilon_\theta(x_t, t, \varnothing)\big). The weight w = 0 gives the unconditional model and w = 1 the conditional one; a weight w > 1 trades diversity for fidelity to the condition c, so the distribution actually sampled is no longer the learned one.

The original paper writes the same rule with w' = w - 1, so its w' = 0 is our w = 1; the Multimodal and Control modules use our form.

The deterministic DDIM sampler (Song, Meng & Ermon 2021) reuses the same trained network with 10 to 50 steps instead of 1\,000: x_{t-1} = \sqrt{\bar\alpha_{t-1}}\,\hat x_0 + \sqrt{1 - \bar\alpha_{t-1}}\,\varepsilon_\theta(x_t, t) \quad \text{with} \quad \hat x_0 = \big(x_t - \sqrt{1 - \bar\alpha_t}\,\varepsilon_\theta(x_t, t)\big)/\sqrt{\bar\alpha_t}. The sampler, not only the model, decides the cost and the quality.

10.5. Deep learning and physics

Physics and deep learning meet in both directions. Networks are used to solve physical problems: emulators trained on simulations (weather models such as GraphCast or FourCastNet produce global forecasts in seconds), and physics-informed networks that are trained to satisfy an equation. And physics supplies ideas to deep learning: diffusion models come from non-equilibrium thermodynamics (Sohl-Dickstein et al. 2015) and sample with Langevin-type dynamics; conservation laws and symmetries become equivariances (section 4.4).

Definition 10.9 — Physics-informed neural network (Raissi, Perdikaris & Karniadakis 2019) To solve a differential equation \mathcal{N}[u] = 0 on a domain, with boundary or initial condition \mathcal{B}[u] = 0, a network u_\theta is trained on the loss \mathcal{L}(\theta) = \frac{1}{N_r}\sum_{j}\big|\mathcal{N}[u_\theta](t_j)\big|^2 + \frac{\lambda}{N_b}\sum_{j}\big|\mathcal{B}[u_\theta](t_j^b)\big|^2 \;\big(+\ \text{a data misfit when measurements exist}\big), where the derivatives in \mathcal{N}[u_\theta] are computed exactly by automatic differentiation with respect to the input coordinates, at collocation points t_j that need no labels.

With measurements, unknown physical coefficients can be fitted at the same time (an inverse problem, analysis-by-synthesis again).

Example 10.10 — The residual identifies the solution Take the decay equation u' + ku = 0 on [0, 1] with u(0) = 1, whose solution is e^{-kt}. To see the mechanism, take the one-parameter family u_a(t) = e^{-at}, which satisfies the initial condition for every a.

The residual is u_a' + ku_a = (k - a)e^{-at}, so the physics loss \frac{1}{N_r}\sum_j (k - a)^2e^{-2at_j} is zero if and only if a = k: the equation alone, with no labelled data, singles out the solution.

A real PINN replaces u_a by an MLP; the loss is then non-convex and can be hard to optimize, notably for stiff or high-frequency solutions, which is the main practical limitation of the method.

Machine-learning forecasts of the El Niño–Southern Oscillation by diffusion models (Y. Zhu, ch. 11.3) illustrate the other route, where a generative model learns the dynamics from data and produces ensembles of plausible futures.

10.6. Cross-references to the other modules

The detail of the generative and multimodal themes lives in the corresponding modules:

Cross-cutting question of the module: where does the border between “advanced vision” and “multimodal” lie? Working answer: as soon as the loss puts two modalities (or two views!) in correspondence, we are in contrast/alignment; as soon as it generates, we are in the generative; the backbones (ch. 3–8) are shared by all.

11. Course research notes (Kalogeiton, Lutzeyer, Zhu, Wang)

The seminar closes with an encounter with local research: each instructor presents a slice of their work, in direct continuation of the chapters. Representative publications (all verified):

11.1. Vicky Kalogeiton — vision, video, action

11.2. Johannes Lutzeyer — graph representation learning

11.3. Ye Zhu — diffusion models, semantic control

11.4. Xi Wang — video generation and generative cinema

Note — How to read a team paper During these sessions, the chapter 1 instruction applies to the instructors’ own work: identify the question, the baseline, the seeds, the budget — and ask the hard questions: this is exactly the scientific exercise the module wants to instill.

Exercises

  1. ★ Patch embedding. For a 224×224 image, patches 16, d = 768: how many tokens, what size for the positional embedding, how many parameters in the projection; compare with patches 14 (ViT-B/14) — attention vs projection FLOPs.
  2. ★ Complexities. Prove the “attention” row of proposition 4.1 (count every matrix product); for n = 196, d = 768, which term dominates; from which n does attention exceed the MLP?
  3. ★ MoE. With n_E = 16, k = 2, d = 1024, expansion r = 4 (hidden width 4096), 24 layers: total parameters, active parameters, FLOPs/token; what fraction of the model can an 80 GB device serve in bf16? (params ≈ 2 GB per billion in bf16.)
  4. ★ Separable. Derive the cost of a MobileNetV2 block (6× pointwise expansion, 3×3 depthwise, pointwise projection to d' channels) as a function of the input width d, of d' and of the map size. For (d, d') = (24, 96): (a) what share of the cost goes to each of the three layers? (b) The depthwise + projection pair replaces a standard 3×3 convolution on the expanded channels: show that the ratio is 1/d' + 1/9 (proposition 3.1 holds for any input width) and that it gives the ~8 factor here.
  5. ★ Seeds. With the numbers of example 1.2, how many seeds would be needed for the 0.5% gap to become significant at 95%? (Statistical power; take \sigma \approx 0.55.)
  6. ★★ Recipe vs architecture. ConvNeXt gains +2.7 points from the training recipe alone; if a future paper compares two architectures with different recipes, by how much might its “gain” be tainted? Propose a fair protocol (def. 1.1).
  7. ★★ Balancing. Use the loss of section 6.1.
      1. Compute \sum_i f_i P_i when the gate probabilities and the routing are both uniform.
      1. Build an example with n_E = 3 experts, top-1 routing and two tokens where \sum_i f_i P_i < 1/n_E: the auxiliary loss is not minimized by balance in general.
      1. Explain why it nevertheless pushes towards balance in practice (look at its gradient with respect to the gate probabilities, f_i being treated as a constant).
      1. Why does the factor n_E in \mathcal{L}_{\mathrm{aux}} make its value at uniform routing independent of the number of experts, and why must f_i be divided by k for this to hold with top-2 routing?
  8. ★★ NT-Xent. Implement the loss of ch. 7 and verify: (a) N = 1 makes the loss degenerate (no negatives — explain the code’s behavior); (b) the gradient with respect to z_i pushes toward z_j and away from the most similar negatives; (c) the effect of \tau \in \{0.1, 0.5, 2\} on the gradient norm.
  9. ★★ MAE. On natural images, why does normalizing each patch by its own mean/variance change the task; estimate the loss of a constant decoder that predicts, for every masked patch, the mean of the visible patches (the bound to beat).
  10. ★★ General Chinchilla. Redo the proof of theorem 9.2 with \alpha \neq \beta and show N^\star \propto C^{\beta/(\alpha+\beta)}, \qquad D^\star \propto C^{\alpha/(\alpha+\beta)}; apply to \alpha = 0.34, \beta = 0.28 (exponents \approx 0.45 and 0.55) and compare with the symmetric case.
  11. ★★ µP sketch. On an MLP of width d with N(0, \sigma^2) initialization, compute the variance of the activations as a function of \sigma^2 and d (one layer); which dependence on d keeps the variance constant; how does this foreshadow hyperparameter transfer?
  12. ★★★ Paper critique. Take the main table of DeiT: identify the baselines, seeds, budgets; what additional experiment would you ask the authors for; write a one-page “review” (structure: summary, strengths, weaknesses, questions).

Projects and assessment

Official assessment. The fiche above quotes the SynapseS 2026–2027 sheet: “a combination of homework, quizzes and team projects”, with “more details later”, and a numerical grade out of 20. The assessment section of the sheet for the LLGA track is not displayed (empty). Everything below is our proposal. The subjects follow the format of chapter 2 — one number, one replication, one budget, the deliverables of section 2.3 (shorter for solo subjects) — and the written exam can serve as the quiz part.

The projects exercise the master objectives O1 (deep learning foundations: architectures, objectives, scaling), O7 (hands-on practice under the replication protocol of definition 1.1) and O8 (trustworthy AI, through the robustness of section 4.5), with O3 (large language models) through the MoE and scaling subjects.

No end-of-year capstone uses this elective as a graded work package, but two group subjects double as ablations there: the self-supervised image tower of group project 2 for Y2.3, and the distilled edge model of group project 3 for the efficient-inference part of Y1.5.

Solo projects

  1. [Solo · ≈ 25 h] A mini-MoE character language model and its routing. It connects this course to Large Language Models (ch. 2) and builds on the block of Deep Learning P1, ch. 6. Question: does load balancing prevent routing collapse, and does a sparse model beat a dense one at equal active compute?
    • Implement: a 6-layer character transformer whose MLPs are replaced by the MoE of section 6.1 (n_E = 8, top-1 and top-2), trained with and without the auxiliary loss; a dense baseline with the same FLOPs per token (proposition 6.2).
    • Data and hardware: enwik8 (the first 100 MB of English Wikipedia, Hutter Prize; the standard 90/5/5 split), Tiny Shakespeare for debugging; one free Colab or Kaggle T4 GPU.
    • Deliverables: code, a 4–6 page report with the curves of f_i over training and a probe of what each expert receives (letters, digits, markup, spaces), a 10-minute talk.
    • Chapters: ch. 1, 6, 9.
    • Success: bits per character with three seeds ± standard deviation for each model; the auxiliary loss at about \alpha_{\mathrm{aux}} under balanced routing, a max/min ratio of the f_i below 2 with the loss, and a documented collapse without it.
  2. [Solo · ≈ 25 h] Paper study: hyperparameter transfer with µP (Yang, Hu et al. 2021, “Tensor Programs V”). Question: on a small model, does the best learning rate stay put as the width grows under µP, and drift under the standard parametrization?
    • Implement: an MLP (and, as a stretch, a 4-layer transformer) at widths 128 to 4 096, parametrized with the table of section 9.3 by hand or with Microsoft’s mup package; sweep Adam’s learning rate over powers of 2 at every width, in both parametrizations.
    • Data and hardware: CIFAR-10 (Krizhevsky 2009) for the MLP, WikiText-2 (Merity et al. 2017) for the transformer; a laptop or one free T4.
    • Deliverables: code, a 4–6 page report with loss-versus-learning-rate curves per width (the format of the paper’s figures 1 and 3), a 10-minute talk.
    • Chapters: ch. 1, 9 (exercise 11).
    • Success: three seeds per point; the optimal learning rate located with an interval at each width; the drift under SP and the stability under µP measured in octaves, or an honest explanation if they do not appear.
  3. [Solo · ≈ 20 h] Paper study: Fourier features and spectral bias (Tancik et al. 2020). Question: how does the scale of a Fourier feature mapping set the trade-off between blur and noise when a field interpolates an image?
    • Implement: the session 7 lab extended — a 4-layer ReLU MLP from (x, y) to RGB, with no mapping, the NeRF encoding of example 10.2, and Gaussian features at scales 1, 10 and 100; a SIREN baseline (Sitzmann et al. 2020).
    • Data and hardware: 512 × 512 crops of DIV2K images (Agustsson & Timofte 2017), trained on every other pixel and tested on the rest, as in the paper; a laptop.
    • Deliverables: code, a 4-page report, a 10-minute talk.
    • Chapters: ch. 1, 10.1.
    • Success: test PSNR with three seeds per mapping; a curve of PSNR against the scale with an interior optimum; the gain over no mapping compared with the paper’s table (about 6 dB on natural images).

Group projects

  1. [Group of 3 · ≈ 30 h each] Recipe or architecture? A fair small-budget ResNet, ConvNeXt and ViT study. Question: once the training recipe is the same, how much of the gap between the three families — in accuracy and in robustness — is left?
    • Implement: a ResNet-18, a small ConvNeXt and a ViT with 4 × 4 patches, at about 11 M parameters each, trained on CIFAR-100 under one shared modern recipe (AdamW, RandAugment, mixup, label smoothing) and under their native recipes; replay steps 1–3 of the ConvNeXt table (ch. 5) at this scale.
    • Robustness, to test the claims of Bai et al. (2021): AutoAttack at \epsilon = 1/255 on the standard-trained models (at 8/255 they all fall to about 0 %); single-step adversarial training at \epsilon = 8/255 (FGSM with a random start, Wong, Rice & Kolter 2020) of the ResNet and the ViT under the shared recipe, evaluated with PGD-10 and AutoAttack on 1 000 test images; mean accuracy on CIFAR-100-C (Hendrycks & Dietterich 2019).
    • Split: member A, ResNet and the shared recipe; member B, ViT; member C, ConvNeXt steps and the robustness harness.
    • Data and hardware: CIFAR-100 and CIFAR-100-C; about 60 T4-hours in all, within the free Kaggle quota of the three members.
    • Deliverables: code, a 6–8 page report (section 2.3), a 15-minute talk.
    • Chapters: ch. 1, 4, 4.5, 5.
    • Success: five seeds per configuration with Welch t-tests; the recipe effect and the architecture effect reported separately; every robustness claim backed by AutoAttack.
  2. [Group of 3 · ≈ 30 h each] A self-supervised backbone shoot-out on STL-10: SimCLR, MAE and DINO. Question: at equal pre-training compute and without labels, which objective gives the best features, and for which evaluation?
    • Implement: SimCLR on a ResNet-18 (ch. 7), MAE on a ViT-Tiny (ch. 8.1), DINO on the same ViT-Tiny (definition 8.3), all at the same GPU-hour budget; a shared evaluation harness — linear probe, k-NN with k = 20, fine-tuning on the 5 000 labelled images.
    • Ablations: SimCLR without colour jitter; MAE at masking ratios of 50, 75 and 90 %; DINO without centering. Check the initial NT-Xent loss against \log(2N - 1) and show the collapse of proposition 7.3 by removing the negatives.
    • Split: one member per method; the harness is shared.
    • Data and hardware: STL-10 (Coates, Ng & Lee 2011): 100 000 unlabelled and 5 000 labelled 96 × 96 images; one free T4 per member.
    • Deliverables: code, a 6–8 page report, a 15-minute talk.
    • Chapters: ch. 1, 7, 8.
    • Success: compute matched within 10 %; three seeds per evaluation; each collapse diagnosed by the standard deviation of the normalized embeddings falling to zero.
  3. [Group of 3 · ≈ 30 h each] Distil and certify: an edge-ready student with robustness guarantees. It connects this course to Computer Vision Applications (ch. 8, deployment). Question: what does distillation cost in accuracy, latency and robustness, and how loose is a Lipschitz certificate?
    • Implement: a ResNet-18 teacher and a MobileNetV2 student trained with the loss of definition 3.2 for T \in \{1, 4, 10\} and \lambda \in \{0.5, 0.9\}; export to ONNX and measure CPU latency (median and 99th percentile); PGD and AutoAttack accuracy; certified radii from proposition 4.7, with L bounded by the product of per-layer spectral norms (power iteration).
    • Split: member A, teacher and distillation sweep; member B, export and latency; member C, attacks and certificates.
    • Data and hardware: CIFAR-10; one free T4 and a laptop CPU for latency.
    • Deliverables: code, a 6–8 page report with an accuracy–latency plot, a 15-minute talk.
    • Chapters: ch. 1, 3, 4.5.
    • Success: three seeds per configuration; the student within 3 points of the teacher at a measured speed-up; certified and empirical robust accuracy reported side by side.

Written exam (proposal)

Format: 2 hours, one handwritten A4 sheet and a non-programmable calculator allowed; four questions on 20 points — a course question, a computation and two short proofs.

  1. Question (5 points). Course. (a) Explain why a Siamese objective that only pulls two views together can be minimized by a useless encoder. (b) Name the mechanism by which SimCLR, BYOL and DINO each avoid this. (c) Why does MAE mask 75 % of the patches where BERT masks 15 % of the tokens, and what does the high ratio save in compute?

    Expected: (a) proposition 7.3: the constant encoder gives similarity 1 for every pair, a global optimum. (b) SimCLR: the negatives in the denominator; BYOL: the asymmetric predictor, the stop-gradient and the momentum target; DINO: centering plus sharpening of the teacher, with a momentum teacher.

    1. Images are spatially redundant, so 15 % is solved by interpolation; at 75 % the task becomes semantic. The encoder sees a quarter of the tokens: token-wise costs fall by 4 and attention by 16.
  2. Question (6 points). Computation. A ViT-S/16 (d = 384, 12 blocks, MLP expansion 4) reads 224 \times 224 images. (a) Number of tokens, parameters per block and in total, forward FLOPs per image. (b) Every MLP becomes a MoE with n_E = 8, top-2: total parameters, active parameters per token. (c) The value of \mathcal{L}_{\mathrm{aux}} under uniform routing with \alpha_{\mathrm{aux}} = 0.01.

    Expected: (a) n = 197; 12d^2 \approx 1.77M per block; with the patch projection (0.29M), about 21.5M in total.

    The forward pass costs 2 \times 21.5\text{M} \times 197 \approx 8.5 GFLOPs, plus attention 12 \times 4n^2 d \approx 0.7 GFLOPs, so about 9.2 GFLOPs (example 4.2).

    1. Per block, attention 4d^2 \approx 0.59M plus 8 \times 8d^2 \approx 9.4M: about 121M in total. Active: 0.59 + 2 \times 1.18 \approx 2.95M per block, about 36M per token.

    2. f_i = P_i = 1/8, so the loss is 0.01 \times 8 \times 8 \times 1/64 = 0.01.

  3. Question (5 points). Short proof: compute-optimal allocation. Minimize A N^{-\alpha} + B D^{-\beta} under 6ND = C with \alpha \neq \beta. Show that N^\star \propto C^{\beta/(\alpha+\beta)} and D^\star \propto C^{\alpha/(\alpha+\beta)}. With (\alpha, \beta) = (0.34, 0.28), by how much does the number of tokens per parameter grow when the budget is multiplied by 10?

    Expected: substitute D = C/(6N); setting the derivative to zero gives N^{\alpha+\beta} = \frac{\alpha A}{\beta B}\,(C/6)^{\beta}, hence the exponent \beta/(\alpha+\beta) \approx 0.45, and D^\star = C/(6N^\star) has exponent \alpha/(\alpha+\beta) \approx 0.55. The ratio D^\star/N^\star grows as C^{0.097}: a factor 10^{0.097} \approx 1.25.

  4. Question (4 points). Short proof: certificate. Prove proposition 4.7. Then take a classifier on 32 \times 32 \times 3 images with margin m = 3 and a bound L = 10: does the certificate cover every \ell_\infty perturbation of one grey level, \epsilon = 1/255?

    Expected: the proof of proposition 4.7 — each logit difference is \sqrt 2 L-Lipschitz, so the margin cannot change sign before \|\delta\|_2 = m/(\sqrt 2 L).

    Here the radius is 3/(10\sqrt 2) \approx 0.212, while the \ell_\infty ball of radius 1/255 reaches \ell_2 norm \sqrt{3072}/255 \approx 0.217: just not covered.

Grading rubric (proposal)

Criterion Weight What earns the marks
Protocol and statistics 25 % definition 1.1 applied: question, hypothesis, fixed split, metric declared in advance, retrained baseline, ablations, at least three seeds with intervals and a named test, compute budget
Correct implementation and derivations 25 % every count, loss and certificate traced to a result of the course; sanity checks (initial loss, auxiliary loss at balance, FLOPs) logged
Analysis of the gap to the paper 20 % paper and replication side by side; each gap attributed to data, recipe, scale or hardware, or flagged as open
Code and reproducibility 15 % one command reruns every table and figure; fixed seeds; public data; the GPU-hours reported
Report and talk 15 % a narrow question answered; the “figure you wish the paper had shown” of section 2.3; honest limitations

References