批量处理还是逐个图像处理?(恐龙V1)

Batch-wise processing or image-by-image processing? (DINO V1)

提问人:Xanta_Kross 提问时间:11/13/2023 最后编辑:Christoph RackwitzXanta_Kross 更新时间:11/13/2023 访问量:30

问:

我一直在尝试为个人项目重新创建 Dino V1 训练设置。为此,我从这个存储库中获取了大部分代码:https://github.com/facebookresearch/dino[dinov1 link]1

rn 我几乎完成了它,除了 main_dino.py 文件中的一部分之外,有一个名为 train_one_epoch 的函数,在第 318 行中他们给出了:

teacher_output= teacher (images[:2]) # only the 2 global views pass through the teacher

现在我知道 pytorch 张量索引/切片是如何工作的。因此,如果图像是结构的一批图像:

(批量大小、作物数量、C、H、W)

  1. 做图像[:2]如何让你获得给定批次中所有图像的全局裁剪?
  2. 他们在这里是批量处理图像,还是这里的“图像”列表只是一个列表,其中包含来自单个输入图像的多个裁剪?
机器学习 深度学习 PyTorch 训练-数据 自监督-学习

评论


答:

1赞 null 11/13/2023 #1

在调用模型之前,对模型进行了另一次修改,学生教师模型都使用 MultiCropWrapper 类进行包装。只需查看该类的文档字符串,如下所示:train_one_epoch()

class MultiCropWrapper(nn.Module):
    """
    Perform forward pass separately on each resolution input.
    The inputs corresponding to a single resolution are clubbed and single
    forward is run on the same resolution inputs. Hence we do several
    forward passes = number of different resolutions used. We then
    concatenate all the output features and run the head forward on these
    concatenated features.
    """

因此,这个 MultiCropWrapper 类处理前向传递,并且还提到它为不同的分辨率执行多个前向传递。