-
In the 3D forwrd function of PatchMerging, it seems x3 equals to x6, which is a little bit beird. MONAI/monai/networks/nets/swin_unetr.py Lines 660 to 701 in 398466c |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi Thanks for pointing out this issue. This seems to be a design option, and also a code typo here.
And yes, after discussion on the 3D, the patch merging should be: x0 = x[:, 0::2, 0::2, 0::2, :]
x1 = x[:, 1::2, 0::2, 0::2, :]
x2 = x[:, 0::2, 1::2, 0::2, :]
x3 = x[:, 0::2, 0::2, 1::2, :]
x4 = x[:, 1::2, 0::2, 1::2, :]
- x5 = x[:, 0::2, 1::2, 0::2, :]
- x6 = x[:, 0::2, 0::2, 1::2, :]
+ x5 = x[:, 1::2, 1::2, 0::2, :]
+ x6 = x[:, 0::2, 1::2, 1::2, :]
x7 = x[:, 1::2, 1::2, 1::2, :]
x = torch.cat([x0, x1, x2, x3, x4, x5, x6, x7], -1) We added patchMergingV2 as follow: Thanks again |
Beta Was this translation helpful? Give feedback.
-
Maybe using a for loop is less error-prone for situation like this, I think XD Something like: x = torch.cat([
x[:, i::2, j::2, k::2, :]
for i, j, k in itertools.product(range(2), range(2), range(2))
], -1) |
Beta Was this translation helpful? Give feedback.
Hi Thanks for pointing out this issue. This seems to be a design option, and also a code typo here.
This issue originate whether to merge and downsample along Z axis, initially, it was
And yes, after discussion on the 3D, the patch merging should be: