Masked Modeling 与 JEPAMasked Modeling & JEPA
把输入遮掉一部分,让网络去猜被遮住的内容:这一个简单的任务不需要任何标签,却迫使网络学会数据的结构。BERT 用它学语言,MAE 用它学图像,JEPA 更进一步:不猜像素,而是猜被遮住部分的“表示”,从而不必为无法预测的细节付出代价,但也必须防止表示塌缩成常数。本节在浏览器里现场训练一个小 MAE 和一个小 JEPA,看清遮挡比例、预测空间和 EMA 目标编码器各起什么作用,最后把预训练好的编码器冻结,用来给机器人估计抓取角度。 Hide part of the input and ask a network to guess what was hidden: this simple task needs no labels at all, yet it forces the network to learn the structure of the data. BERT learns language this way and MAE learns images; JEPA goes one step further and guesses not the pixels but the representation of the hidden part, so it does not pay for details that cannot be predicted, at the price of having to stop the representation from collapsing to a constant. In this lesson you train a small MAE and a small JEPA live in the browser, see what the mask ratio, the prediction space and the EMA target encoder each do, and finally freeze the pretrained encoders and use them to estimate a grasp angle for a robot.
1为什么机器人需要它Why robots need this
一台机械臂的腕部相机每秒产生几十帧图像。要让它学会抓取,最直接的办法是监督学习:人工标注每张图里物体在哪、该从什么角度抓,再训练一个网络(16.1 节)。问题是标注很贵,而机器人演示数据更贵:一条遥操作演示要人花几十秒到几分钟(22.3 节),一个任务通常只有几十到几百条。从零训练的视觉网络在这么少的数据上很容易过拟合(16.2 节)。
可没有标签的图像几乎是免费的:机器人自己乱动时拍的视频、互联网上的视频、人做家务的第一人称视频。自监督学习的思路是:从数据本身造出一个“题目”,让网络在海量无标签数据上做题,学到一个好的表示(representation),再用少量标注数据把它接到具体任务上(21.1 节讲微调)。18.3 节的对比学习是一种题目:“这两张图是不是同一个东西的两种增强?”本节讲另一类,也是今天大模型最常用的一类:遮住一部分,猜回来(masked modeling)。
它从语言开始。BERT 把句子里 15% 的词遮住,让 Transformer 根据两侧的上下文猜它们;GPT 一类的自回归模型(19.4 节)只看左侧,猜下一个词。图像上,MAE(masked autoencoder)把 75% 的图块遮住,只把剩下的图块送进编码器,再用一个小解码器重建全部像素。JEPA(joint-embedding predictive architecture)则认为重建像素是在浪费力气:被遮住的那块地毯上每根绒毛的样子本来就猜不出来。它改成在表示空间里预测:用一个目标编码器把被遮住的区域编码成向量,让预测器去猜这个向量。这样做省掉了像素细节,却引入了一个新危险:如果编码器把所有东西都编码成同一个常数,“猜”就永远是对的,这叫表示塌缩。I-JEPA、V-JEPA,以及 BYOL、DINO 等方法都靠停止梯度、指数滑动平均(EMA)目标编码器和预测器这一类设计来避免它。
对机器人来说,结果是一批可以直接拿来用的预训练视觉编码器:MVP 系列工作在大量第一人称视频上用 MAE 预训练 ViT,冻结后接一个小策略网络,比 CLIP 或 ImageNet 监督预训练的编码器更适合操作任务;V-JEPA 2 进一步把 JEPA 编码器和一个动作条件预测器组合成世界模型,用来规划抓放。本节最后(FIG 6)会在一个小例子里亲手体会这一点:预训练让一个原本难以从像素读出的量(工具的朝向)变得可以用几十条标注读出。
The wrist camera of a robot arm produces dozens of frames per second. The most direct way to teach it grasping is supervised learning: label every image by hand with where the object is and from which angle to grasp it, then train a network (Lesson 16.1). The trouble is that labels are expensive and robot demonstrations even more so: one teleoperated demonstration costs a person tens of seconds to minutes (Lesson 22.3), and a task usually has only tens to hundreds of them. A vision network trained from scratch on so little data overfits easily (Lesson 16.2).
Unlabelled images, on the other hand, are nearly free: video the robot records while moving around, internet video, first-person video of people doing chores. The idea of self-supervised learning is to build a "puzzle" out of the data itself, let the network solve it on huge amounts of unlabelled data so that it learns a good representation, and then attach that representation to a concrete task with a few labelled examples (fine-tuning is Lesson 21.1). The contrastive learning of Lesson 18.3 is one kind of puzzle: "are these two images two augmentations of the same thing?" This lesson covers the other kind, the one most used by today's large models: hide a part and guess it back (masked modeling).
It started with language. BERT hides 15% of the words of a sentence and lets a Transformer guess them from the context on both sides; autoregressive models such as GPT (Lesson 19.4) see only the left side and guess the next word. For images, MAE (the masked autoencoder) hides 75% of the image patches, sends only the remaining patches through the encoder, and reconstructs all pixels with a small decoder. JEPA (the joint-embedding predictive architecture) argues that reconstructing pixels wastes effort: the exact look of every fibre on a hidden piece of carpet cannot be guessed anyway. It predicts in representation space instead: a target encoder turns the hidden region into a vector and a predictor has to guess that vector. This drops the pixel detail but introduces a new danger: if the encoder maps everything to the same constant, every "guess" is right. This is representation collapse. I-JEPA, V-JEPA, BYOL, DINO and their relatives avoid it with designs such as a stop-gradient, an exponential-moving-average (EMA) target encoder and a predictor.
For robots the result is a family of ready-to-use pretrained visual encoders: the MVP line of work pretrains ViTs with MAE on large amounts of first-person video, freezes them and attaches a small policy network, and finds them better suited to manipulation than CLIP or ImageNet-supervised encoders; V-JEPA 2 goes further and combines a JEPA encoder with an action-conditioned predictor into a world model used to plan pick-and-place. At the end of this lesson (FIG 6) you experience this on a small example: pretraining makes a quantity that is hard to read from raw pixels (the orientation of a tool) readable from a few dozen labels.
2直觉:填空题逼你理解结构Intuition: a fill-in-the-blank test forces you to understand the structure
先从语言开始。下面是一个只有 180 句话的小语料库,全是给机器人的指令,形如“grab the red cube and put it in the bowl”。它有几条隐藏规则:颜色和物体可以随便组合;容器 bowl、box 用介词 in,tray、shelf 用 on;动词 drop 只能配 in。你点一个词把它遮住(变成 [MASK]),图里就给出在这个语料库上能达到的最好预测:数一数所有与未遮住的词一致的句子,被遮住的位置上各个词出现的比例。这正是一个无限大、训练完美的 BERT 会给出的分布。左栏用两侧的上下文,右栏只用左侧(像 GPT 那样)。每栏下面的 \(\hl{H}{H}\) 是这个分布的熵(4.11 节),单位是比特:0 表示确定,\(\log_2 3\approx1.58\) 表示三选一完全不确定。
Start with language. Below is a tiny corpus of 180 sentences, all of them commands for a robot, like "grab the red cube and put it in the bowl". It has a few hidden rules: colours and objects combine freely; the containers bowl and box take the preposition in, tray and shelf take on; the verb drop only goes with in. Click a word to hide it (it becomes [MASK]) and the figure shows the best possible prediction on this corpus: count every sentence that agrees with the unmasked words and take the fraction of each word at the hidden position. This is exactly the distribution an infinitely large, perfectly trained BERT would output. The left panel uses the context on both sides, the right panel only the left side (as GPT would). Under each panel, \(\hl{H}{H}\) is the entropy of the distribution (Lesson 4.11) in bits: 0 means certain, \(\log_2 3\approx1.58\) means a completely uncertain choice among three.
- 在一个动词不是 drop 的句子里只遮住介词(in 或 on):看两侧时它是确定的(\(H=0\)),只看左侧时却有 1 比特的不确定性。是右边的容器词泄露了答案。In a sentence whose verb is not drop, hide only the preposition (in or on): with both sides it is certain (\(H=0\)), with the left side only it carries 1 bit of uncertainty. The container word on the right gives the answer away.
反过来,在动词不是 drop 的句子里把介词和后面的容器一起遮住,再看介词:两侧上下文也帮不上忙了,\(H\) 回到 1 比特。遮得越多,题越难。再遮一下颜色词:无论看哪边都是 1.58 比特,因为语料里没有任何东西决定颜色。这种不可约的不确定性很重要:一个被训练去预测颜色的模型,最好也只能输出三分之一、三分之一、三分之一,损失永远降不到零,也不应该降到零。语言里这样的词不多,因为词本身已经是高度压缩的符号;可图像里到处都是这样的东西:一片纹理里每个像素的精确值、传感器噪声、反光的形状。下面看图像。
FIG 2 用的是本节贯穿始终的玩具图像:一台俯视桌面的机器人相机拍到的 12×12 像素画面,上方是背景,下方是桌面(边缘的高度和倾斜随机),桌上放着一根棒状工具(位置和朝向随机)。图像切成 36 个 2×2 的图块(patch),这和 ViT 把 224×224 的图像切成 16×16 的图块是同一个做法(17.3 节)。遮住一些图块,最笨的猜法是插值:用附近可见像素的加权平均填进去(权重与距离的四次方成反比);另一个笨办法是不看图,直接填上整个数据集的平均图像。
Conversely, in a sentence whose verb is not drop, hide the preposition and the container after it together and look at the preposition: now even both sides cannot help, and \(H\) is back to 1 bit. The more you hide, the harder the puzzle. Now hide a colour word: 1.58 bits whichever side you look at, because nothing in the corpus decides the colour. This irreducible uncertainty matters: a model trained to predict the colour can at best output one third, one third, one third; its loss never reaches zero, and it should not. Language has few such words because words are already highly compressed symbols; images are full of them: the exact value of every pixel of a texture, sensor noise, the shape of a reflection. On to images.
FIG 2 uses the toy image that runs through this lesson: a 12×12-pixel view from a robot camera looking down at a table. The top is background, the bottom is the table (the height and tilt of its edge are random), and on the table lies a rod-shaped tool (random position and orientation). The image is cut into 36 patches of 2×2 pixels, the same thing a ViT does when it cuts a 224×224 image into 16×16 patches (Lesson 17.3). Hide some patches. The dumbest guess is interpolation: fill in a weighted average of nearby visible pixels (weights inversely proportional to the fourth power of the distance); another dumb option ignores the image and fills in the dataset's mean image.
- 把遮挡数拉到紫线越过虚线的地方(约 26/36,即 72%)及以上:平均而言,插值已经不比“不看图直接填平均图像”更好了。Push the masked count to where the purple line crosses the dashed one (about 26/36, i.e. 72%) or beyond: on average, interpolation is then no better than ignoring the image and filling in the mean image.
- 用点击的方式只遮住工具经过的全部图块(红框),总遮挡数不超过 18(一半):图像大部分可见,插值却把工具整个抹掉了。By clicking, hide exactly every patch the tool passes through (the red boxes), with no more than 18 patches (half) hidden in total: most of the image is visible, yet interpolation wipes the tool out completely.
图像的空间冗余很大:只遮一两成时,被遮的像素几乎全能由邻居插值出来,这样的题目学不到什么东西。MAE 的第一个发现就是要遮得很多(75%):这时局部插值失效,只有理解了“桌沿是一条直线”“工具是一根有方向的棒”这类全局结构,才能猜对。语言则不同,词的信息密度很高,BERT 只遮 15% 就已经是难题。遮挡比例要和数据的冗余程度相配。
Images are spatially very redundant: with only a tenth or two hidden, the masked pixels can almost all be interpolated from their neighbours, and such a puzzle teaches little. MAE's first finding is to mask a lot (75%): then local interpolation fails, and only an understanding of global structure ("the table edge is a straight line", "the tool is a rod with a direction") gets the answer right. Language is different: words are dense in information, and BERT's 15% is already a hard puzzle. The mask ratio has to match how redundant the data is.
3动手:现场训练一个 MAEPlay: train an MAE live
现在训练一个真正学结构的模型。它是一个小小的“masked autoencoder”:输入是遮挡后的图像(被遮的像素置 0)加上 36 个标志位,告诉网络哪些图块被遮住了;网络是 180 → 64 → 64 → 144 的 MLP(GELU 激活,用本课程的 nn.js 实现),输出完整的 144 个像素。损失只算在被遮住的像素上:可见像素原样抄过去毫无意义。每一步从生成器里新抽 32 张图、每张随机遮挡,用 Adam(学习率 0.002)更新一次。数据无穷无尽,所以这里没有过拟合,测试集只是固定的 200 张图和固定的遮挡,用来公平地画曲线。
真正的 MAE 有两点不同。第一,编码器是 ViT,只处理可见图块(遮 75% 时只有四分之一的 token),解码器很轻,在编码结果中插入“mask token”后重建全部图块,所以训练又快又省(FIG 5)。第二,预测目标通常是每个图块内归一化后的像素。我们的 MLP 没有 token 的概念,只能用“置零加标志位”的方式告诉它哪里被遮住了,但训练目标与 MAE 完全一样。
Now train a model that really learns the structure. It is a tiny "masked autoencoder": the input is the masked image (masked pixels set to 0) plus 36 flags that tell the network which patches are hidden; the network is a 180 → 64 → 64 → 144 MLP (GELU activations, built with the course's nn.js), and its output is the full 144 pixels. The loss is computed only on the masked pixels: copying the visible ones through teaches nothing. Every step draws 32 fresh images from the generator, masks each at random, and makes one Adam update (learning rate 0.002). The data never runs out, so there is no overfitting here; the test set is just 200 fixed images with fixed masks so that the curves are fair.
The real MAE differs in two ways. First, its encoder is a ViT that processes only the visible patches (a quarter of the tokens at 75% masking), and a light decoder inserts "mask tokens" among the encoded patches and reconstructs all patches, which makes training fast and cheap (FIG 5). Second, the target is usually the pixels of each patch after per-patch normalization. Our MLP has no notion of tokens, so it can only be told where the holes are by "zeros plus flags", but its training objective is exactly the MAE objective.
- 默认设置(遮 27/36 = 75%,无噪声)按“训练”:约 1500 步后,MAE 的误差比插值低 25% 以上(读数里的“比插值低”)。看重建图:桌沿被画成了直线,工具虽然模糊,却大致出现在对的位置。With the defaults (27/36 = 75% masked, no noise) press "Train": after about 1500 steps the MAE error is more than 25% below interpolation ("below interpolation" in the readout). Look at the reconstructions: the table edge comes out as a straight line, and the tool, although blurry, appears roughly in the right place.
- 改成遮 32/36(89%)并训练:这时插值比平均图像还差,而 MAE 只看 4 个图块,仍然比两者都好(比两者中较好的低 8% 以上,约 1000 步)。Switch to 32/36 masked (89%) and train: now interpolation is worse than the mean image, while the MAE, seeing only 4 patches, still beats both (more than 8% below the better of the two, after about 1000 steps).
- 打开像素噪声(σ = 0.1 或 0.2)并训练至少 1000 步:误差曲线始终停在红色点线(σ²)之上。噪声是不可预测的,重建像素的模型要为它付出永远无法消除的损失,重建图也只能是“平均后的模糊”。Switch on pixel noise (σ = 0.1 or 0.2) and train for at least 1000 steps: the error curve stays above the red dotted line (σ²) throughout. The noise is unpredictable, so a model that reconstructs pixels pays a loss for it that can never be removed, and its reconstructions can only be an "averaged blur".
(1) 在 75% 遮挡下,3000 步后 MAE 的测试误差约 0.028,插值约 0.040,平均图像约 0.041:模型确实学到了插值学不到的全局结构。(2) 重建是模糊的。这不是缺陷,而是均方误差的必然:当被遮的内容有多种可能时(工具藏在哪里?),最小化 MSE 的最优输出是所有可能的条件平均(第 5 节)。(3) 加 σ = 0.2 的噪声后误差停在 0.07 左右,远高于 σ² = 0.04:噪声不只抬高了“地板”,还污染了输入,让结构也更难看清。
(1) At 75% masking the MAE's test error after 3000 steps is about 0.028, interpolation about 0.040 and the mean image about 0.041: the model really has learned global structure that interpolation cannot. (2) The reconstructions are blurry. This is not a defect but a necessity of the squared error: when the hidden content has several possibilities (where is the tool hiding?), the output that minimizes the MSE is the conditional mean of all of them (Section 5). (3) With σ = 0.2 noise the error settles around 0.07, well above σ² = 0.04: the noise does not just raise the floor, it also corrupts the input and makes the structure harder to see.
4换个预测空间:JEPA 与塌缩A different prediction space: JEPA and collapse
不猜像素,猜表示Predict the representation, not the pixels
FIG 3 暴露了像素重建的两个问题。一是浪费:模型的容量和梯度有很大一部分花在噪声、纹理这类本来就猜不出来的细节上(FIG 1 的颜色词、FIG 3 的噪声地板)。二是目标不对:机器人要的是“工具在哪、朝哪”,而不是每个像素的亮度,最小化像素误差并不直接奖励前者。Yann LeCun 在 2022 年的立场论文里提出的 JEPA 换了一个目标:把输入分成上下文 \(x\) 和目标 \(y\),用编码器分别把它们变成表示,让预测器从 \(x\) 的表示预测 \(y\) 的表示:
FIG 3 exposed two problems of pixel reconstruction. The first is waste: much of the model's capacity and gradient goes into details that cannot be guessed anyway, such as noise and texture (the colour word of FIG 1, the noise floor of FIG 3). The second is the wrong target: a robot wants "where is the tool and which way does it point", not the brightness of every pixel, and minimizing pixel error does not directly reward the former. The JEPA, proposed by Yann LeCun in a 2022 position paper, changes the target: split the input into a context \(x\) and a target \(y\), turn each into a representation with an encoder, and let a predictor predict the representation of \(y\) from that of \(x\):
\(f_\theta\) 是上下文编码器(被训练的那个),\(g_\phi\) 是预测器,\(f_\xi\) 是目标编码器:它不被梯度训练,而是上下文编码器参数的指数滑动平均(EMA,\(\tau\) 接近 1)。\(\operatorname{sg}\) 表示停止梯度(stop-gradient):反向传播时把目标当成常数。LN 是层归一化(17.3 节),把每个目标向量减去均值、除以标准差。I-JEPA 中 \(x\) 是图像里一大块上下文区域的图块,\(y\) 是另外 4 个目标块,预测器还被告知目标块的位置;V-JEPA 把这套搬到视频上。我们的玩具做了简化:上下文是 FIG 3 那样遮掉 75% 的图像,目标是整幅图像的一个 8 维表示,编码器与 MAE 的前两层同构(180 → 64 → 64 → 8),预测器是 8 → 32 → 8。
危险在于:上面的损失有一个平凡的全局最小值。若编码器对任何输入都输出同一个向量,预测器只要输出这个常数,损失就是零。这叫完全塌缩,得到的表示没有任何信息。18.3 节的对比学习靠负样本防止它:InfoNCE 要求不同图像的表示彼此分开。JEPA 没有负样本,它靠的是结构上的不对称:只有一侧有预测器,另一侧停止梯度、缓慢地跟随(EMA)。下面的实验比较“有这套不对称”和“把梯度也传进目标一侧”两种情况。衡量塌缩的指标是展开度 \(\hl{spread}{s}\):150 张测试图的目标表示在每一维上的标准差的平均。完全塌缩时 \(s=0\)。
\(f_\theta\) is the context encoder (the one being trained), \(g_\phi\) the predictor, and \(f_\xi\) the target encoder: it is not trained by gradients but is an exponential moving average (EMA, \(\tau\) close to 1) of the context encoder's parameters. \(\operatorname{sg}\) is the stop-gradient: backpropagation treats the target as a constant. LN is layer normalization (Lesson 17.3), which subtracts the mean of each target vector and divides by its standard deviation. In I-JEPA, \(x\) is the patches of one large context region of the image, \(y\) is four other target blocks, and the predictor is also told the target positions; V-JEPA carries the same recipe over to video. Our toy simplifies: the context is the 75%-masked image of FIG 3, the target is one 8-dimensional representation of the whole image, the encoders have the shape of the MAE's first two layers (180 → 64 → 64 → 8), and the predictor is 8 → 32 → 8.
The danger: this loss has a trivial global minimum. If the encoder outputs the same vector for every input, the predictor need only output that constant and the loss is zero. This is complete collapse, and the representation carries no information at all. The contrastive learning of Lesson 18.3 prevents it with negatives: InfoNCE demands that the representations of different images stay apart. JEPA has no negatives. It relies on a structural asymmetry instead: only one side has a predictor, while the other side stops the gradient and follows slowly (EMA). The experiment below compares "with this asymmetry" and "gradient also flows into the target side". The collapse indicator is the spread \(\hl{spread}{s}\): the standard deviation of the target representations of 150 test images along each dimension, averaged over dimensions. Complete collapse means \(s=0\).
- 选“不停止梯度”并训练:不到 50 步展开度就跌到 0.05 以下,点云缩成一点,损失几乎为零。损失最低的模型,表示最没用。Choose "no stop-gradient" and train: within 50 steps the spread falls below 0.05, the cloud shrinks to a point and the loss is nearly zero. The model with the lowest loss has the most useless representation.
- 换回 JEPA(\(\tau=0.99\))训练到 2000 步以上:展开度一直保持在 0.3 以上(实际不低于 0.45),损失停在约 0.08 到 0.2 之间,点云始终散开。Switch back to JEPA (\(\tau=0.99\)) and train past 2000 steps: the spread stays above 0.3 throughout (in fact never below 0.45), the loss stays between about 0.08 and 0.2, and the cloud stays spread out.
- 把 \(\tau\) 设为 0(目标编码器就是当前编码器的拷贝,但仍停止梯度)并训练:展开度先跌到 0.1 以下(约 450 步时最低,约 0.04),之后又回升到 0.3 以上。EMA 越慢,早期越稳。Set \(\tau\) to 0 (the target encoder is a copy of the current encoder, still behind a stop-gradient) and train: the spread first dips below 0.1 (lowest, about 0.04, near step 450) and then climbs back above 0.3. The slower the EMA, the steadier the early phase.
这个小实验和文献的结论一致:把梯度传进目标一侧,网络立刻找到平凡解;停止梯度加预测器就能避开它(SimSiam 显示,甚至 \(\tau=0\) 也行,我们的玩具里它先差点塌缩、再恢复);EMA 让目标慢慢变化,训练更稳。四档 \(\tau\) 在 4000 步内的最低展开度分别约为 0.04(\(\tau=0\))、0.11(0.9)、0.45(0.99)和 0.55(0.999,从未低于初值 0.53)。真实系统用的 \(\tau\) 更接近 1:I-JEPA 从 0.996 线性增加到 1.0。要注意,为什么这套不对称能防止塌缩,目前没有完整的理论保证(第 5 节);塌缩的解依然存在,只是训练动力学通常不会走到那里。
This little experiment agrees with the literature: let the gradient into the target side and the network finds the trivial solution at once; a stop-gradient plus a predictor avoids it (SimSiam showed that even \(\tau=0\) works; in our toy it first nearly collapses and then recovers); the EMA makes the target change slowly and training steadier. Within 4000 steps the lowest spread for the four settings of \(\tau\) is about 0.04 (\(\tau=0\)), 0.11 (0.9), 0.45 (0.99) and 0.55 (0.999, never below its starting value of 0.53). Real systems use \(\tau\) even closer to 1: I-JEPA increases it linearly from 0.996 to 1.0. Note that there is no complete theoretical guarantee for why this asymmetry prevents collapse (Section 5); the collapsed solution still exists, the training dynamics just usually do not go there.
BYOL(Grill 等,2020)最早证明“没有负样本也能学”:同一张图的两个增强视图,一个进在线网络加预测器,一个进 EMA 目标网络,预测对方的归一化表示。SimSiam(Chen 与 He,2021)去掉 EMA(\(\tau=0\)),发现只要有停止梯度和预测器就不塌缩,去掉预测器则塌缩。DINO(Caron 等,2021)让学生网络去匹配 EMA 教师网络输出的 softmax 分布,用“中心化”(减去教师输出的滑动均值,防止一个维度独大)和“锐化”(教师用更低的温度,防止输出变成均匀分布)两个相反的力互相制衡;DINOv2 是今天机器人里常用的冻结视觉编码器之一。这三者都靠手工设计的数据增强(裁剪、颜色抖动)来定义“同一个东西”。JEPA 用遮挡代替增强:上下文和目标来自同一张图(或同一段视频)的不同部分,所以不需要知道哪些变化“无关紧要”。data2vec(Baevski 等,2022)用同样的思路统一了语音、语言和图像。
BYOL (Grill et al., 2020) first showed that learning works without negatives: two augmented views of one image go one through an online network plus predictor, the other through an EMA target network, and each predicts the other's normalized representation. SimSiam (Chen & He, 2021) dropped the EMA (\(\tau=0\)) and found that a stop-gradient and a predictor are enough to avoid collapse, while removing the predictor makes it collapse. DINO (Caron et al., 2021) makes a student network match the softmax distribution of an EMA teacher, and balances two opposite forces: "centering" (subtract a running mean of the teacher outputs, so that no single dimension dominates) and "sharpening" (a lower teacher temperature, so that the output does not become uniform); DINOv2 is one of the frozen visual encoders robots use most today. All three rely on hand-designed augmentations (crops, colour jitter) to define "the same thing". JEPA replaces augmentation by masking: context and target come from different parts of the same image (or video), so it does not need to know in advance which changes "do not matter". data2vec (Baevski et al., 2022) used the same idea to unify speech, language and images.
怎么遮:MAE、I-JEPA 与 V-JEPAHow to mask: MAE, I-JEPA and V-JEPA
遮挡策略决定了题目的难度,也决定了计算量。下图在一个 14×14 的 token 网格上(224×224 的图像、16×16 的图块)画出三种策略。MAE 随机遮 75% 的图块,编码器只处理剩下的 49 个。I-JEPA 先随机取 4 个目标块(每块占图像的 15% 到 20%,宽高比 0.75 到 1.5),再取一个占 85% 到 100% 的方形上下文块,并从上下文里删去与目标重叠的部分:目标块要大到有“语义”,上下文要足够分散。V-JEPA 把同样的空间块在所有时间步上重复,形成贯穿整段视频的“管道”,否则模型只需从相邻帧抄过来;它有两种掩码:8 个占 15% 的块的并集(短程),和 2 个占 70% 的块的并集(长程)。
The masking strategy sets the difficulty of the puzzle and also the amount of compute. The figure draws three strategies on a 14×14 token grid (a 224×224 image with 16×16 patches). MAE masks 75% of the patches at random, and its encoder processes only the 49 that remain. I-JEPA first samples 4 target blocks (each covering 15% to 20% of the image, aspect ratio 0.75 to 1.5), then a square context block covering 85% to 100%, and removes from the context everything that overlaps a target: the targets have to be large enough to be "semantic", and the context spread out enough to be informative. V-JEPA repeats the same spatial blocks at every time step, forming "tubes" through the whole clip, because otherwise the model could simply copy from a neighbouring frame; it uses two kinds of mask: the union of 8 blocks of 15% each (short range) and the union of 2 blocks of 70% each (long range).
- MAE 模式下把遮挡比例拉到 90% 或以上:编码器只看 20 个以下的 token,计算量降到一次完整前向的 10% 以下。这就是 MAE 能把大模型的预训练加速 3 倍以上的原因。In MAE mode push the mask ratio to 90% or more: the encoder sees 20 tokens or fewer and its compute drops below 10% of a full forward pass. This is why MAE speeds up the pretraining of large models by 3× or more.
在我们的采样器里(块的位置均匀随机,大小取整到网格),I-JEPA 的上下文平均保留约 90 个 token(46%),4 个目标的并集平均约 94 个(48%);V-JEPA 的长程掩码平均遮住约 84%,短程约 63%。论文报告的平均遮挡比例约为 90%,与我们的简化采样器不完全一样。不论细节,三者的共同点是:被预测的部分很大,而且不能靠局部复制得到。
In our sampler (block positions uniformly random, sizes rounded to the grid), the I-JEPA context keeps about 90 tokens on average (46%), and the union of the 4 targets averages about 94 (48%); V-JEPA's long-range mask hides about 84% on average and the short-range one about 63%. The paper reports an average masking ratio of about 90%, which our simplified sampler does not reproduce exactly. Whatever the details, all three share one feature: the predicted part is large and cannot be obtained by copying locally.
5再看数学The math
提示:把鼠标悬停在公式中带底色的符号上,图中对应的元素会被高亮(FIG 1 的熵、FIG 3 的遮挡图块与噪声地板、FIG 4 的目标表示与展开度、FIG 5 的上下文 token、FIG 6 的探针曲线)。Tip: hover the highlighted symbols in the formulas; the matching elements in the figures light up (the entropies of FIG 1, the masked patches and the noise floor of FIG 3, the target representations and the spread of FIG 4, the context tokens of FIG 5, the probe curves of FIG 6).
遮挡建模的目标The masked-modeling objective
设输入由 \(n\) 个 token(词或图块)组成,\(\hl{mask}{\mathcal M}\subset\{1,\dots,n\}\) 是随机抽出的遮挡集合,\(x_{\setminus\mathcal M}\) 是可见部分。遮挡建模最小化
Let the input consist of \(n\) tokens (words or patches), let \(\hl{mask}{\mathcal M}\subset\{1,\dots,n\}\) be a randomly drawn mask set, and \(x_{\setminus\mathcal M}\) the visible part. Masked modeling minimizes
BERT 的 token 是词,\(\ell\) 是交叉熵(16.1 节),\(|\mathcal M|\approx0.15n\);被选中的位置 80% 换成 [MASK]、10% 换成随机词、10% 保持不变,因为下游使用时输入里不会出现 [MASK]。MAE 的 token 是图块,\(\ell\) 是平方误差,\(|\mathcal M|=0.75n\)。两者的最优预测器都可以写出来。在交叉熵下,最优输出就是条件分布 \(p(x_i\mid x_{\setminus\mathcal M})\),最小损失是条件熵:
For BERT the tokens are words, \(\ell\) is the cross-entropy (Lesson 16.1) and \(|\mathcal M|\approx0.15n\); of the chosen positions 80% are replaced by [MASK], 10% by a random word and 10% are left unchanged, because [MASK] never appears in the input at downstream time. For MAE the tokens are patches, \(\ell\) is the squared error and \(|\mathcal M|=0.75n\). In both cases the optimal predictor can be written down. Under the cross-entropy the optimal output is the conditional distribution \(p(x_i\mid x_{\setminus\mathcal M})\), and the minimal loss is the conditional entropy:
这就是 FIG 1 显示的数:两侧上下文时介词的条件熵为 0,颜色为 \(\log_23\)。在平方误差下,最优输出是条件均值,最小损失是条件方差:
This is the number FIG 1 shows: with both sides the conditional entropy of the preposition is 0 and that of the colour is \(\log_23\). Under the squared error the optimal output is the conditional mean and the minimal loss is the conditional variance:
证明只需一行:对任意 \(c\),\(\mathbb E[(c-x)^2]=(c-\mathbb E x)^2+\operatorname{Var}x\),在 \(c=\mathbb E x\) 时最小(4.3 节)。两个后果在 FIG 3 里都看到了:被遮内容有多种可能时,最优重建是它们的平均,所以是模糊的;若像素带有与一切无关的噪声 \(\varepsilon\sim\mathcal N(0,\sigma^2)\),条件方差至少是 \(\sigma^2\),损失永远不会低于这条地板。
The proof is one line: for any \(c\), \(\mathbb E[(c-x)^2]=(c-\mathbb E x)^2+\operatorname{Var}x\), which is minimal at \(c=\mathbb E x\) (Lesson 4.3). Both consequences showed up in FIG 3: when the hidden content has several possibilities, the optimal reconstruction is their average, hence blurry; and if pixels carry noise \(\varepsilon\sim\mathcal N(0,\sigma^2)\) independent of everything else, the conditional variance is at least \(\sigma^2\), and the loss never goes below that floor.
MAE 为什么快Why MAE is fast
一层宽度为 \(D\) 的 Transformer 处理 \(n\) 个 token 时,QKV 和输出投影约 \(4nD^2\) 次乘加,MLP(隐藏层 \(4D\))约 \(8nD^2\),注意力矩阵及其加权约 \(2n^2D\);按每次乘加 2 次运算算,一层约 \(24nD^2+4n^2D\) 次浮点运算(17.3 节)。MAE 编码器只处理 \(\hl{ctx}{n_{\mathrm{vis}}}=(1-r)n\) 个 token:
One Transformer layer of width \(D\) on \(n\) tokens needs about \(4nD^2\) multiply-adds for the QKV and output projections, about \(8nD^2\) for the MLP (hidden width \(4D\)) and about \(2n^2D\) for the attention matrix and its weighted sum; at 2 operations per multiply-add that is about \(24nD^2+4n^2D\) flops per layer (Lesson 17.3). The MAE encoder processes only \(\hl{ctx}{n_{\mathrm{vis}}}=(1-r)n\) tokens:
其中 \(C(n)=24nD^2+4n^2D\),近似在 token 数远小于 \(6D\) 时成立。图像只有 196 个 token、\(D=1024\) 时,注意力只占一层计算的约 3%,所以编码器的计算量几乎与可见比例成正比:遮 75% 时约为 24%(FIG 5)。解码器很浅很窄,MAE 论文报告每个 token 的计算量不到编码器的 10%。视频的 token 多得多(V-JEPA 是 \(8\times14\times14=1568\) 个),注意力的 \(n^2\) 项更重,高遮挡比例省下的就更多。
Here \(C(n)=24nD^2+4n^2D\), and the approximation holds when the token count is much smaller than \(6D\). With only 196 image tokens and \(D=1024\), attention is about 3% of a layer's compute, so the encoder's cost is almost proportional to the visible fraction: about 24% at 75% masking (FIG 5). The decoder is shallow and narrow; the MAE paper reports less than 10% of the encoder's computation per token. Video has many more tokens (\(8\times14\times14=1568\) for V-JEPA), the \(n^2\) attention term weighs more, and a high mask ratio saves even more.
JEPA、EMA 与塌缩JEPA, the EMA and collapse
本节玩具 JEPA 的损失是 \(\frac1d\|g_\phi(f_\theta(x))-\operatorname{sg}(\bar{\mathbf z})\|^2\),\(d=8\)。I-JEPA 对每个目标图块的表示做同样的 L2 回归并取平均,V-JEPA 换成了 L1。EMA 更新 \(\xi_{t+1}=\tau\xi_t+(1-\tau)\theta_{t+1}\) 展开后是
The loss of the toy JEPA in this lesson is \(\frac1d\|g_\phi(f_\theta(x))-\operatorname{sg}(\bar{\mathbf z})\|^2\) with \(d=8\). I-JEPA performs the same L2 regression on the representation of every target patch and averages, and V-JEPA switches to L1. Unrolled, the EMA update \(\xi_{t+1}=\tau\xi_t+(1-\tau)\theta_{t+1}\) is
第二个式子是权重的平均“年龄”:目标编码器是过去约 \(1/(1-\tau)\) 步在线参数的加权平均(初值的影响按 \(\tau^t\) 消失):\(\tau=0.99\) 约 100 步,\(\tau=0.996\) 约 250 步。为什么不塌缩?先看塌缩为什么会发生。若不停止梯度,目标 \(\bar{\mathbf z}\) 对 \(\theta\) 的导数也进入更新,梯度下降同时把预测拉向目标、把目标拉向预测;而让所有表示都相等是同时满足两者的最省事办法。FIG 4 里这只用了不到 50 步。停止梯度后,目标在每一步都是常数,编码器只能通过让上下文的表示更好地预测目标来降低损失。BYOL 的作者给出过一个启发式解释(V-JEPA 的论文把它改写成 L1 损失的版本,那时最优预测器是条件中位数):对平方误差,若预测器始终接近最优,即 \(g^\star=\mathbb E[\bar{\mathbf z}\mid f_\theta(x)]\),那么损失就等于给定上下文表示时目标的条件方差,编码器的梯度会推动上下文表示携带尽可能多关于目标的信息;EMA 让目标变得比预测器慢,使预测器能一直保持在最优附近。Tian 等(2021)在线性网络上分析了这套动力学,说明预测器和停止梯度共同使塌缩解不再吸引训练。这些都是解释,不是对一般非线性网络的证明;实践中通常还要监控展开度或表示的有效秩。
与对比学习的关系:18.3 节的 InfoNCE 可以拆成两项,一项把正样本对拉近(“对齐”),一项把所有样本推开(“均匀”)。非对比方法只保留了对齐项,用结构上的不对称(BYOL、SimSiam、JEPA)、输出分布的中心化与锐化(DINO),或显式的方差与协方差正则(VICReg,Bardes 等,2022)去代替均匀项。下面是 DINO 的损失,\(\mathbf z_t,\mathbf z_s\) 是教师和学生的输出,\(\mathbf c\) 是中心,\(m\) 是它的动量,教师温度 \(T_t\) 低于学生温度 \(T_s\):
The second expression is the mean "age" of the weights: the target encoder is a weighted average of the online parameters of roughly the last \(1/(1-\tau)\) steps (the initial value fades like \(\tau^t\)): about 100 steps for \(\tau=0.99\), about 250 for \(\tau=0.996\). Why no collapse? First, why collapse happens. Without the stop-gradient, the derivative of the target \(\bar{\mathbf z}\) with respect to \(\theta\) also enters the update, so gradient descent pulls the prediction towards the target and the target towards the prediction at the same time, and making every representation equal is the cheapest way to satisfy both. In FIG 4 this took fewer than 50 steps. With the stop-gradient the target is a constant at every step, and the encoder can lower the loss only by making the context representation a better predictor of the target. The BYOL authors gave a heuristic explanation (the V-JEPA paper adapts it to its L1 loss, for which the optimal predictor is the conditional median): for the squared error, if the predictor stays close to optimal, \(g^\star=\mathbb E[\bar{\mathbf z}\mid f_\theta(x)]\), the loss equals the conditional variance of the target given the context representation, and the encoder's gradient pushes the context representation to carry as much information about the target as possible; the EMA makes the target move more slowly than the predictor, so the predictor can stay near its optimum. Tian et al. (2021) analysed these dynamics for linear networks and showed how the predictor and the stop-gradient together keep the collapsed solution from attracting training. These are explanations, not proofs for general nonlinear networks; in practice one also monitors the spread or the effective rank of the representation.
Relation to contrastive learning: the InfoNCE of Lesson 18.3 splits into two terms, one pulling positive pairs together ("alignment") and one pushing all samples apart ("uniformity"). Non-contrastive methods keep only the alignment term and replace the uniformity term with a structural asymmetry (BYOL, SimSiam, JEPA), with centering and sharpening of the output distribution (DINO), or with explicit variance and covariance regularization (VICReg, Bardes et al., 2022). Below is DINO's loss, with \(\mathbf z_t,\mathbf z_s\) the teacher and student outputs, \(\mathbf c\) the centre with momentum \(m\), and a teacher temperature \(T_t\) below the student's \(T_s\):
冻结编码器 + 线性探针Frozen encoder + linear probe
评价一个表示最常用的办法是线性探针:冻结编码器,取特征 \(\phi(x)\in\R^{p}\),只用 \(N\) 个标注样本拟合一个线性映射。FIG 6 用岭回归(1.13 节最小二乘加 L2 正则),\(\lambda=1\),偏置不惩罚:
The most common way to evaluate a representation is a linear probe: freeze the encoder, take the features \(\phi(x)\in\R^{p}\), and fit only a linear map with \(N\) labelled examples. FIG 6 uses ridge regression (the least squares of Lesson 1.13 plus an L2 penalty) with \(\lambda=1\) and an unpenalized bias:
式中 \(\Phi\) 的每一行是一个样本的特征,先减去 \(N\) 个样本的均值(于是偏置单独求出、不受惩罚)。工具是一根直棒,转 180° 后样子不变,所以它的朝向 \(\alpha\) 只在模 180° 意义下有定义;用 \((\cos2\alpha,\sin2\alpha)\) 表示朝向,可以避开 0° 与 180° 处的跳变,预测后再用 \(\tfrac12\operatorname{atan2}\) 取回角度。线性探针测的是“信息是否以线性可读的形式存在”。全量微调(21.1 节)会改变编码器本身,往往得分更高;MAE 的特征就以“线性探针一般、微调很强”著称,而 I-JEPA 的论文报告它的线性探针明显好于 MAE。
Each row of \(\Phi\) is one example's features, centred by subtracting the mean over the \(N\) examples (so the bias is fitted separately and not penalized). The tool is a straight rod and looks the same after a 180° turn, so its orientation \(\alpha\) is only defined modulo 180°; writing it as \((\cos2\alpha,\sin2\alpha)\) avoids the jump between 0° and 180°, and the angle comes back as \(\tfrac12\operatorname{atan2}\) of the prediction. A linear probe measures "is the information there in a linearly readable form". Full fine-tuning (Lesson 21.1) changes the encoder itself and often scores higher; MAE features are known for "mediocre linear probe, strong fine-tuning", and the I-JEPA paper reports clearly better linear probes than MAE.
6机器人中的它:冻结的预训练编码器In robotics: frozen pretrained encoders
MVP 的配方很简单:先在大量无标签图像上用 MAE 预训练一个视觉编码器,冻结它,再在它的特征上用很少的机器人数据训练一个小策略。下图在玩具世界里重演这个配方。机器人要抓桌上的工具,需要知道两件事:抓取点(工具中心,像素坐标)和夹爪的偏航角(工具的朝向)。先不用任何标签,各训练 2000 步的 MAE 和 JEPA;然后冻结,取每个编码器两层隐藏层的 128 个激活作为特征,用 \(N\) 张有标注的图拟合线性探针,在另外 300 张图上测误差。对照组是原始像素(144 维)和一个结构相同、但没训练过的随机编码器。
The MVP recipe is simple: pretrain a visual encoder with MAE on lots of unlabelled images, freeze it, and train a small policy on its features with very little robot data. The figure replays this recipe in the toy world. To grasp the tool on the table the robot needs two things: the grasp point (the tool's centre, in pixels) and the gripper yaw (the tool's orientation). First, with no labels at all, train an MAE and a JEPA for 2000 steps each; then freeze them, take the 128 activations of each encoder's two hidden layers as features, fit a linear probe on \(N\) labelled images and measure the error on 300 other images. The controls are the raw pixels (144 numbers) and a random encoder with the same architecture that was never trained.
- 按“预训练”跑完 2000 步,目标选“偏航角”,\(N=100\):MAE 和 JEPA 的误差都比原始像素低 4° 以上(约 15° 对 22°),而随机编码器不比像素好:起作用的是预训练,不是网络结构。Press "Pretrain" and let it finish 2000 steps, choose the target "yaw" and \(N=100\): both the MAE and the JEPA errors are more than 4° below the raw pixels (about 15° versus 22°), while the random encoder is no better than pixels: what helps is the pretraining, not the architecture.
- 预训练完成后把目标换成“抓取点”:这次原始像素反而最好(\(N=100\) 时约 0.8 px,预训练特征约 1.3 px)。工具中心差不多就是高亮度像素的质心,本来就是像素的线性函数。After pretraining switch the target to "grasp point": this time the raw pixels are best (about 0.8 px at \(N=100\), about 1.3 px for the pretrained features). The tool centre is roughly the centroid of the high-intensity pixels, already a linear function of the pixels.
这个小结果包含了真实系统里的两条经验。第一,预训练的价值在于把原始输入里非线性地纠缠在一起的量(朝向需要比较像素之间的关系)变成可以用少量标签读出来的形式;300 个标注时,像素探针的偏航角误差约 19°,MAE 和 JEPA 约 11°。第二,冻结的通用特征不一定保留任务需要的每个细节:精确的位置信息在压缩时可能丢失一部分。真实的机器人系统因此常常把冻结的视觉特征和本体感受(关节角、夹爪状态)一起输入策略,或者在机器人数据上再做微调。
This small result contains two lessons from real systems. First, the value of pretraining is that it turns quantities that are nonlinearly entangled in the raw input (orientation requires comparing pixels with each other) into a form that a few labels can read out; with 300 labels the pixel probe's yaw error is about 19°, the MAE's and JEPA's about 11°. Second, frozen general-purpose features do not necessarily keep every detail a task needs: some precise position information can be lost in the compression. Real robot systems therefore often feed frozen visual features into the policy together with proprioception (joint angles, gripper state), or fine-tune on robot data.
MVP(Xiao、Radosavovic、Darrell、Malik,2022)在真实世界的图像(包括第一人称视频的帧)上用 MAE 预训练 ViT,冻结后用强化学习在仿真里训练控制器,比监督预训练的编码器成功率最多高 80 个百分点,并发现来自野外视频的图像比 ImageNet 更适合操作任务。真实机器人上的 MVP(Radosavovic 等,CoRL 2022)把规模加到 3.07 亿参数的 ViT、450 万张来自互联网和第一人称视频的图像,冻结编码器,在多种真实机器人和任务上训练策略,报告比 CLIP(最多 75%)、ImageNet 监督预训练和从零训练(最多 81%)都好。VC-1(Majumdar 等,NeurIPS 2023)系统比较了多种预训练视觉表示在许多具身任务上的表现,结论是没有一个编码器在所有任务上都最好,适配到目标任务仍然重要。VLA:OpenVLA 的视觉部分把自监督的 DINOv2 特征和语言对齐的 SigLIP 特征拼在一起(Part VII)。世界模型:V-JEPA 2(Meta,2025)先在大规模视频上用 JEPA 预训练编码器,再冻结它,用不到 62 小时的 DROID 无标签机器人视频训练一个动作条件的预测器 V-JEPA 2-AC,在两个实验室的 Franka 机械臂上朝目标图像在表示空间里规划,零样本完成抓放。这与 24.3 节不重建像素的潜空间世界模型(如 TD-MPC)是同一个思想:在表示空间里预测未来。
MVP (Xiao, Radosavovic, Darrell & Malik, 2022) pretrained ViTs with MAE on real-world images (including frames of first-person video), froze them, and trained controllers with reinforcement learning in simulation; it beat supervised-pretrained encoders by up to 80 percentage points of success rate and found in-the-wild video images better suited to manipulation than ImageNet. MVP on real robots (Radosavovic et al., CoRL 2022) scaled this to a 307M-parameter ViT and 4.5M images from the internet and first-person video, kept the encoder frozen and trained policies for a range of real-world tasks and robots, reporting gains over CLIP (up to 75%), ImageNet-supervised pretraining and training from scratch (up to 81%). VC-1 (Majumdar et al., NeurIPS 2023) compared many pretrained visual representations on many embodied tasks and concluded that no single encoder is best everywhere and that adapting to the target task still matters. VLAs: the vision part of OpenVLA concatenates self-supervised DINOv2 features with language-aligned SigLIP features (Part VII). World models: V-JEPA 2 (Meta, 2025) pretrains a JEPA encoder on large-scale video, freezes it, and trains an action-conditioned predictor, V-JEPA 2-AC, on less than 62 hours of unlabelled robot video from DROID; on Franka arms in two labs it plans in representation space towards a goal image and does pick-and-place zero-shot. This is the same idea as the latent world models of Lesson 24.3 that do not reconstruct pixels (such as TD-MPC): predict the future in representation space.
7常见误区Common pitfalls
15% 对语言是难题,对图像几乎是送分题(FIG 2:遮 25% 时插值的误差只有平均图像的一半左右);视频的冗余更大,V-JEPA 平均遮约 90%,还必须沿时间方向整管地遮,否则模型从相邻帧抄就行。遮挡比例、块的大小和形状要按数据的冗余程度来调。
15% is a hard puzzle for language and almost a giveaway for images (FIG 2: at 25% masking interpolation has about half the error of the mean image); video is even more redundant, and V-JEPA hides about 90% on average and must hide whole tubes along time, or the model just copies from neighbouring frames. Tune the mask ratio and the block size and shape to how redundant the data is.
MAE 的重建是模糊的(条件均值),这既不是坏事,也不说明表示好坏;预训练损失的大小同样说明不了表示能不能用。要评价表示,就在下游任务上测:线性探针、少样本微调,或者直接看机器人策略的成功率。FIG 6 还说明不同任务的结论可以相反:同一套特征对朝向有帮助,对位置却不如原始像素。
MAE reconstructions are blurry (the conditional mean); this is neither bad nor evidence about the representation, and the size of the pretraining loss tells you just as little about whether the representation is useful. Evaluate a representation downstream: a linear probe, few-shot fine-tuning, or simply the success rate of a robot policy. FIG 6 also shows that the verdict can flip between tasks: the same features help with orientation and lose to raw pixels on position.
在表示空间里预测,损失接近零往往是塌缩的信号(FIG 4 的“不停止梯度”)。忘了 stop-gradient、把目标编码器也交给优化器、目标编码器与在线编码器共享了某个可训练的模块,都会造成这种 bug。训练时一定要监控表示的展开度(各维标准差)或有效秩;部分塌缩(只剩少数几个维度在变)比完全塌缩更难发现。
When predicting in representation space, a loss near zero is often the sign of collapse (FIG 4's "no stop-gradient"). Forgetting the stop-gradient, handing the target encoder to the optimizer, or letting the target and online encoders share a trainable module all produce this bug. Always monitor the spread (per-dimension standard deviation) or the effective rank of the representation during training; partial collapse (only a few dimensions still varying) is harder to spot than complete collapse.
\(\tau\) 决定目标编码器平均了多少步(约 \(1/(1-\tau)\))。太小,目标追得太快,训练早期容易接近塌缩(FIG 4 里 \(\tau=0\) 时展开度先跌到 0.04);太接近 1,目标几乎不动,学得很慢。常见做法是从 0.996 左右开始,在训练过程中逐渐增加到 1。改了批大小或总步数时也要相应地调整,因为“多少步”的含义变了。还要记住下游评估用哪个编码器:I-JEPA 用的是目标编码器。
\(\tau\) sets how many steps the target encoder averages over (about \(1/(1-\tau)\)). Too small and the target chases too fast, so early training can come close to collapse (in FIG 4 the spread first falls to 0.04 at \(\tau=0\)); too close to 1 and the target barely moves and learning is slow. A common choice starts around 0.996 and increases it towards 1 during training. Adjust it when you change the batch size or the total number of steps, because "how many steps" then means something else. Also remember which encoder to evaluate downstream: I-JEPA uses the target encoder.
互联网图像和机器人腕部相机的画面差别很大:视角、畸变、运动模糊、夹爪总在画面里。冻结的特征可能丢掉任务需要的精确几何(FIG 6 里的抓取点),VC-1 的比较也说明没有一个编码器在所有具身任务上都最好。稳妥的做法是:在自己的数据上用线性探针或小规模微调先验证,把本体感受一起输入策略,必要时在机器人视频上继续做自监督预训练。
Internet images and a robot's wrist camera look very different: viewpoint, distortion, motion blur, a gripper that is always in the frame. Frozen features can lose the precise geometry a task needs (the grasp point in FIG 6), and the VC-1 comparison shows that no single encoder is best on all embodied tasks. The safe route: verify first on your own data with a linear probe or small-scale fine-tuning, feed proprioception into the policy as well, and if needed continue self-supervised pretraining on robot video.
8小练习Check yourself
9延伸阅读Further reading
- J. Devlin, M.-W. Chang, K. Lee & K. Toutanova, BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, NAACL 2019 — 遮挡语言建模(15%,80/10/10 规则)masked language modeling (15%, the 80/10/10 rule)
- K. He, X. Chen, S. Xie, Y. Li, P. Dollár & R. Girshick, Masked Autoencoders Are Scalable Vision Learners, CVPR 2022 — MAE:75% 遮挡、只编码可见图块、轻量解码器MAE: 75% masking, encoding only visible patches, a light decoder
- H. Bao, L. Dong, S. Piao & F. Wei, BEiT: BERT Pre-Training of Image Transformers, ICLR 2022 — 预测离散视觉 token 的遮挡图像建模masked image modeling that predicts discrete visual tokens
- J.-B. Grill et al., Bootstrap Your Own Latent: A New Approach to Self-Supervised Learning, NeurIPS 2020 — BYOL:没有负样本,用预测器与 EMA 目标网络BYOL: no negatives, a predictor and an EMA target network
- X. Chen & K. He, Exploring Simple Siamese Representation Learning, CVPR 2021 — SimSiam:停止梯度是防止塌缩的关键SimSiam: the stop-gradient is the key to avoiding collapse
- M. Caron et al., Emerging Properties in Self-Supervised Vision Transformers, ICCV 2021 — DINO:自蒸馏、中心化与锐化DINO: self-distillation, centering and sharpening
- Y. Tian, X. Chen & S. Ganguli, Understanding Self-Supervised Learning Dynamics without Contrastive Pairs, ICML 2021 — 为什么预测器与停止梯度能避免塌缩(线性网络分析)why a predictor and a stop-gradient avoid collapse (an analysis of linear networks)
- Y. LeCun, A Path Towards Autonomous Machine Intelligence, position paper, 2022 — 提出 JEPA 与在表示空间里预测的世界模型proposes JEPA and world models that predict in representation space
- M. Assran et al., Self-Supervised Learning from Images with a Joint-Embedding Predictive Architecture, CVPR 2023 — I-JEPA:多块遮挡、EMA 目标编码器I-JEPA: multi-block masking, an EMA target encoder
- A. Bardes et al., Revisiting Feature Prediction for Learning Visual Representations from Video, arXiv 2024 — V-JEPA:在视频上用 L1 预测特征、时空管道遮挡V-JEPA: L1 feature prediction on video with spatiotemporal tube masking
- T. Xiao, I. Radosavovic, T. Darrell & J. Malik, Masked Visual Pre-training for Motor Control, arXiv 2022; I. Radosavovic et al., Real-World Robot Learning with Masked Visual Pre-training, CoRL 2022 — MVP:冻结的 MAE 编码器用于机器人控制MVP: frozen MAE encoders for robot control
- A. Majumdar et al., Where are we in the search for an Artificial Visual Cortex for Embodied Intelligence?, NeurIPS 2023 — VC-1:预训练视觉表示在具身任务上的系统比较VC-1: a systematic comparison of pretrained visual representations on embodied tasks