lucidrains / g-mlp-pytorch

Implementation of gMLP, an all-MLP replacement for Transformers, in Pytorch
MIT License
417 stars 58 forks source link

Custom image sizes? #7

Closed danarte closed 2 years ago

danarte commented 3 years ago

Hi, Thanks for your great (and very fast) contribution! I was wondering if you could help me figure out how to apply this to a different image size? It's not really an image, but rather a 2D dimensional tensor of 4096X100.

I saw that I can change the number of channels, so I could just set channels to be 1. But I see that firstly - your implementation is for squared images, and secondly, it requires that image size should be devisable by patch size.

Since you've written this implementation perhaps you could help me to adapt it for my needs? (and maybe other users for their cases).

Maybe I could pad the length to be 128 so both would be devisable by 16 for example? but then where do I set different h, w ?

Thanks.

lucidrains commented 3 years ago

@danarte Hi! Do you want to let me know if https://github.com/lucidrains/g-mlp-pytorch/commit/6549354944bd8fea79fa441538eafcf7f40fba93 suits your needs?

lucidrains commented 3 years ago

I think padding and using the feature in my latest release will work well!

danarte commented 3 years ago

@lucidrains Thanks for the speedy update! I'll check it in the next few days, but it already looks like it should work perfectly for my case.