You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytorch implementation of our paper: Sliced Recursive Transformer (ECCV 2022), Zhiqiang Shen, Zechun Liu and Eric Xing.
FLOPs and Params Comparison
Our Approach
Recursion operation:
Sliced Group Self-Attention:
Abstract
We present a neat yet effective recursive operation on vision transformers that can improve parameter utilization without involving additional parameters. This is achieved by sharing weights across the depth of transformer networks. The proposed method can obtain a substantial gain of about 2% simply using naive recursive operation, requires no special or sophisticated knowledge for designing principles of networks, and introduces minimal computational overhead to the training procedure. To reduce the additional computation caused by recursive operation while maintaining the superior accuracy, we propose an approximating method through multiple sliced group self-attentions across recursive layers which can reduce the cost consumption by 10~30% with minimal performance loss. We call our model Sliced Recursive Transformer (SReT), a novel and parameter-efficient vision transformer design that is compatible with a broad range of other designs for efficient ViT architectures. Our best model establishes significant improvement on ImageNet-1K over state-of-the-art methods while containing fewer parameters. The flexible scalability has shown great potential for scaling up models and constructing extremely deep vision transformers.
Train SReT models with knowledge distillation (recommend training with FKD, which is faster with higher performance):
importtorchimportimportSReTimportkd_losscriterion_kd=kd_loss.KDLoss()
model=SReT.SReT_S_distill(pretrained=False)
student_outputs=model(images)
...
# we use the soft label only for distillation procedure as MEAL V2# Note that 'student_outputs' and 'teacher_outputs' are logits before softmaxloss=criterion_kd(student_outputs/T, teacher_outputs/T)
...
Pre-trained Model
We currently provide the last epoch checkpoints and will add the best ones together with more models soon. (⋇ indicates without slice.) We notice that using a larger initial lr (0.001 $\times$$batchsize \over 512$) with longer warmup epochs = 30 can obtain better results on SReT.
If you find our code is helpful for your research, please cite:
@article{shen2021sliced,
title={Sliced Recursive Transformer},
author={Zhiqiang Shen and Zechun Liu and Eric Xing},
year={2021},
journal={arXiv preprint arXiv:2111.05297}
}
Contact
Zhiqiang Shen (zhiqiangshen0214 at gmail.com or zhiqians at andrew.cmu.edu)
About
Official PyTorch implementation of our ECCV 2022 paper "Sliced Recursive Transformer"