chinhsuanwu / coatnet-pytorch

A PyTorch implementation of "CoAtNet: Marrying Convolution and Attention for All Data Sizes"
https://arxiv.org/abs/2106.04803
MIT License
365 stars 67 forks source link

An error occurs when an image of 512 size is given as input. #5

Closed jeongHwarr closed 2 years ago

jeongHwarr commented 2 years ago

Hello.I really aprreciate for your project.

However, The following error occurs when a 512-size image is input at Attention class.

dots = dots + relative_bias RuntimeError: The size of tensor a (1024) must match the size of tensor b (196) at non-singleton dimension 3.

https://github.com/chinhsuanwu/coatnet-pytorch/blob/d3ef1c3e4d6dfcc0b5f731e46774885686062452/coatnet.py#L155

Why this error is occured? How do I edit your code when I want to resize the image?

Thank you!

chinhsuanwu commented 2 years ago

Hi @jeongHwarr

If you are not using images with size 224x224, you should modify the first argument in CoAtNet. For example,

net = CoAtNet((512, 512), 3, num_blocks, channels, num_classes=1000)
jeongHwarr commented 2 years ago

@chinhsuanwu Oh.. my.. I forgot that! I really really thank you so much! Have a good day. Thank you for your contribution!