Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swin Transformer V2 基于LiBai复现 (关于CCF的pr整合) #359

Open
shaoshitong opened this issue Aug 15, 2022 · 2 comments
Open

Swin Transformer V2 基于LiBai复现 (关于CCF的pr整合) #359

shaoshitong opened this issue Aug 15, 2022 · 2 comments

Comments

@shaoshitong
Copy link
Contributor

项目介绍

Swin-Transformer V2 [Liu et al.2021] 是微软对原有 Swin-Transformer 的继续深入研究。原有的 Swin-Transformer 通过引入图像自身的先验知识(shift 窗口来实现)在图像分类,目标检测,语义分割上取得了良好的性能。然而由于一系列问题: 大模型训练产生的激活阈值过大,下游任务的分辨率太大而预训练的分辨率太低导致相对位置编码损害了性能,以及预训练需要大量标记数据的问题。作者分别采用将 Layernorm 移动至 MLP 以及 Attention 的后方,采用 log-spaced 的元网络生成,利用 SimMIM 来辅助训练解决了上述问题。最后设计了一个具备 3 亿参数量的模型在众多数据集上取得了极为优异的性能。本课题的目标便是通过 Libai 复现网络,并且能够拓展模型,支持各种并行形式的训练。并在 ImageNet-21k, ImageNet-1k V1, V2 上进行完整训练,达到论文中的基准线。

模型和示例

模型介绍

模型架构大致和Swin Transformer基本相同,除了以下三点不同需要改动:

  1. 将LayerNorm移动至MLP和Attention的后方

  2. 通过余弦计算相似度替换原来的内积

  3. 使用元网络来实现相对位置编码,同时应用log-based实现

具体可以见下图:
teaserv6.pdf

实现难点

  1. 各种并行训练的实现,以及精度对齐问题。
  2. Oneflow和Pytorch算子的一些不对齐问题。

可借鉴的代码

  1. libai中原有关于VIT,Swin的实现
  2. facebook官方关于SwinV2的实现

中期考核前提交的pr

@shaoshitong
Copy link
Contributor Author

shaoshitong commented Aug 29, 2022

关于swin精度不对齐问题,在commit

@shaoshitong
Copy link
Contributor Author

精度不对齐详细讨论在:#366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant