YtongXie / CoTr

[MICCAI2021] CoTr: Efficiently Bridging CNN and Transformer for 3D Medical Image Segmentation
GNU General Public License v3.0
288 stars 45 forks source link

RuntimeError: The size of tensor a (6) must match the size of tensor b (5) at non-singleton dimension 4 #7

Closed VatsalBambhania closed 2 weeks ago

VatsalBambhania commented 1 year ago

Hi, I'm trying to train the CoTr model on Hippocampus dataset that I downloaded from http://medicaldecathlon.com/ However, I'm getting the error that the size of the tensors when performing the in skip connection operation doesn't match.

image

The error is basically somewhere in the CoTr/network_architecture/ResTranUnet.py line 156 x = x + skip2

I tried to solve the issue but I don't fully understand the source of the error. Any help will be really appreciated

Thank you

YtongXie commented 1 year ago

Could you print the shape of x and skip2?

VatsalBambhania commented 1 year ago

Hi, So nevermind, actually my input shape was not multiple of 4 and after second block it was equating to an odd number, so at this line it tried to add the two values, I was getting this error. I solved it by changing input shape to multiple of 8.

Thanks for you replay.

Regards, Vatsal