尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

视觉特征提取器-训练范式02-自监督-联合嵌入预测02:V-JEPA【ViT 视频切块、3D Mask、双编码器与 Predictor 原理详解】

视觉特征提取器-训练范式02-自监督-联合嵌入预测02:V-JEPA【ViT 视频切块、3D Mask、双编码器与 Predictor 原理详解】 V-JEPA训练流程解析http://arxiv.org/abs/2404.08471We use a Vision Transformer (ViT) (Dosovitskiy et al., 202o; Arnab et al., 2021) as our video backbone. To process a videowith a transformer network, we split the video clip into a 3D grid of L spatio-temporal patches, where a patch consists of a16 × 16 pixel block spanning 2 consecutive frames; we refer to these spatio-temporal patches as tokens. This sequence oftokens is then directly processed by the stack of transformer blocks. Inputs x and y correspond to masked regions of avideo, we apply the video masks by simply dropping a subset of the tokens. We apply masking at the input of the x-encoder,and at the output of the y-encoder to construct contextualized targets (Baevski et al., 2o22b). The encoder is parameterizedusing standard ViT networks, while the predictor is a narrow transformer implemented using 12 blocks with an embeddingdimension of 384. Taking inspiration from masked autoencoders (He et al., 2021), our predictor takes as input thesequence of embeddings produced by the x-encoder as well as a sequence of learnable mask tokens with positionalembeddings indicating the spatio-temporal positions of the y tokens. The output of the predictor is an embedding vector for each mask token; see Figure 3 and refer to Appendix B for more details.结合mermaid图或其他示例图详细解释上述过程我会先对照论文原文和 Figure 3,把这段话里的视频切块、mask、x-encoder / y-encoder、predictor、target embedding的数据流核对清楚,然后用一张 Mermaid 流程图和一个具体的“几帧视频切成 token”的例子拆开讲。论文这里有一个很容易读反的关键点:x xx-encoder(上下文编码器,context encoder)是“先丢掉被遮挡 token,再编码”;而y yy-encoder(目标编码器,target encoder)是“先看完整视频,再只取被遮挡位置的输出作为目标”。因此,y yy不是被单独裁出来再编码,而是带有完整上下文的目标特征(contextualized targets)。这段讲的正是V-JEPA(Video Joint-Embedding Predictive Architecture,视频联合嵌入预测架构)的核心训练流程。最关键的一点是:它并不是让模型“补出被遮住的视频像素”,而是让模型根据可见视频区域,去预测被遮挡区域在特征空间(feature space)中应该具有怎样的表示。论文将这一思路作为视频自监督预训练的核心目标。turn762163academia19一、原文严格翻译我们使用视觉 Transformer(Vision Transformer, ViT)(Dosovitskiy 等,2020;Arnab 等,2021)作为我们的视频骨干网络(video backbone)。为了使用 Transformer 网络处理视频,我们将视频片段划分成一个由L LL个时空块(spatio-temporal patches)构成的三维网格,其中每个块由一个跨越连续2 22帧的16 × 16 16\times1616×16像素区域组成;我们将这些时空块称为词元(tokens)。随后,这一 token 序列会被直接送入一系列 Transformer 块进行处理。输入x xx和y yy分别对应视频中的被掩码区域。我们通过简单地丢弃一部分 token 来应用视频掩码(video masks)。具体而言,我们在x xx-编码器(x xx-encoder)的输入端应用掩码,而在y yy-编码器(y yy-encoder)的输出端应用掩码,以构造上下文化目标(contextualized targets)(Baevski 等,2022b)。编码器采用标准的 ViT 网络进行参数化,而预测器(predictor)是一个较窄的 Transformer,由12 1212个 Transformer 块构成,其嵌入维度(embedding dimension)为384 384384。受到掩码自编码器(Masked Autoencoders, MAE)(He 等,2021)的启发,我们的预测器接收两部分输入:一部分是由x xx-encoder 产生的嵌入序列;另一部分是一系列可学习的掩码 token(learnable mask tokens),这些 mask token 带有位置嵌入(positional embeddings),用于指示对应y yytoken 在视频中的时空位置。预测器会为每一个 mask token 输出一个嵌入向量。具体结构见论文 Figure 3,并可参考附录中的进一步说明。二、先看整个 V-JEPA 数据流下面这张图基本可以理解成 Figure 3 的逻辑展开版:EMA parameter updateVideo ClipT × H × W × 33D Patch Embedding2 × 16 × 16L Spatio-temporal TokensDrop masked tokensx-encoderContext EncoderVisible embeddingsz_NPredictorLearnable Mask Tokens+ 3D Positional EmbeddingsPredicted target featuresŝ_My-encoderTarget EncoderSelect masked positionsTarget features s_ML1 Feature Loss这里实际上存在两条路线:上面一条路线负责“猜”:视频 → mask →x xx-encoder → predictor → 被遮挡区域的预测特征。下面一条路线负责提供“标准答案”:完整视频 →y yy-encoder → 被遮挡位置的真实目标特征。然后比较两者:预测特征 s ^ k vs. 目标特征 s k \text{预测特征}\quad\hat{s}_k\qquad\text{vs.}\qquad\text{目标特征}\quad s_k预测特征s^k​vs.目标特征sk​论文使用L 1 L_1L1​回归损失(L 1 L_1L1​regression loss)让二者接近。y yy-encoder 的参数不是通过这项损失直接反向传播更新,而是通过x xx-encoder 参数的指数移动平均(Exponential Moving Average, EMA)更新。turn947020view2三、第 1 步:先把视频变成 token这是理解整个流程的第一道坎。普通 ViT 处理图片时,可以把一张图片切成:16 × 16 16\times1616×16的小块。而现在处理的是视频,因此多了一个时间维度(temporal dimension)。V-JEPA 的一个 token 实际对应:2 × 16 × 16 2\times16\times162×16×16其中:2 22:连续两帧;16 1616:高度方向16 1616个像素;16 1616:宽度方向16 1616个像素。所以它不是一个普通的二维 patch,而可以想象成一个很薄的三维小立方体(3D tubelet)。例如:Frame t Frame t+1 +--------+ +--------+ | | | | | 16×16 | ───────────► | 16×16 | | | | | +--------+ +--------+ Together = one 2×16×16 token也就是说,这一个 token 同时包含了一点点:空间信息(spatial information) + 时间信息(temporal information)。四、真实模型里一共有多少 token?论文附录给出了一个非常具体的例子。输入视频为16 1616帧,每帧大小:224 × 224 224\times224224×224因此原始输入张量可以写成:16 × 224 × 224 × 3 16\times224\times224\times316×224
返回列表