vit-pytorch icon indicating copy to clipboard operation
vit-pytorch copied to clipboard

T2TViT Performer backbone

Open hussam789 opened this issue 3 years ago • 1 comments

Hey, Can I simply use performer (or other efficient transformers) in T2TViT similar to the original paper?

hussam789 avatar Feb 25 '21 12:02 hussam789

@hussam789 sounds good! in 0.7.6 you can do

import torch
from vit_pytorch.t2t import T2TViT
from performer_pytorch import Performer

performer = Performer(
    dim = 512,
    depth = 2,
    heads = 8
)

v = T2TViT(
    dim = 512,
    image_size = 224,
    num_classes = 1000,
    transformer = performer,
    t2t_layers = ((7, 4), (3, 2), (3, 2))
)

img = torch.randn(1, 3, 224, 224)
v(img) # (1, 1000)

lucidrains avatar Feb 26 '21 04:02 lucidrains