Llama3VisionEncoder¶
- class torchtune.models.llama3_2_vision.Llama3VisionEncoder(clip: Module, projection_head: Module)[source]¶
Llama 3.2 Vision的视觉编码器模型。该模型结合了预训练的视觉编码器和一个可学习的投影头。投影头被转换为融合模块,并支持融合工具。
- Parameters:
clip (nn.Module) – CLIP编码器视觉模型
projection_head (nn.Module) – 投影头,接收维度为encoder_dim的嵌入作为输入,并输出大小为decoder_dim的嵌入。
- forward(images: Tensor, aspect_ratio: Optional[Tensor] = None) Tensor[source]¶
- Parameters:
images (torch.Tensor) – 图像张量,形状为 [b x i x t x c x w x h]
aspect_ratio (可选[torch.Tensor]) – 形状为 [b x i x 2] 的张量。如果所有 图像只有一个图块,即它们没有被图块裁剪,则应为 None。 用于计算图块的位置嵌入。
- Returns:
- 输出嵌入序列的张量 [b x s x d]
其中序列长度为 num_imgs*num_tiles+num_embeds
- Return type:
张量
- 用于张量形状的符号表示:
b: 批量大小
i: 图像数量
t: 瓦片数量(其中单个图像被分割成多个瓦片)
c: 图像通道数量(例如 rgb = 3)
w: 图像宽度
h: 图像高度
s: 由 i*t*clip_embeds_per_tile 计算的序列长度
d: 嵌入维度