I got the below error when trying to test it with the synapse dataset. Notice this problem appears only when I used "MERIT_GCASCADE" but not with "PVT_GCASCADE".
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
Input In [2], in MERIT_GCASCADE.forward(self, x)
408 x = self.conv_1cto3c(x)
410 # transformer backbone as encoder
--> 411 f1 = self.backbone1(F.interpolate(x, size=self.img_size_s1, mode=self.interpolation))
412 #print([f1[3].shape,f1[2].shape,f1[1].shape,f1[0].shape])
413
414 # decoder
415 x11_o, x12_o, x13_o, x14_o = self.decoder1(f1[3], [f1[2], f1[1], f1[0]])
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1730, in MaxxVit.forward(self, x)
1729 def forward(self, x):
-> 1730 x = self.forward_features(x)
1731 #x = self.forward_head(x)
1732 return x
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1714, in MaxxVit.forward_features(self, x)
1712 features = []
1713 for i in range(len(self.stages)):
-> 1714 x = self.stages[i](x)
1715 #print(x.shape)
1716 if(i==len(self.stages)-1):
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1550, in MaxxVitStage.forward(self, x)
1548 x = checkpoint_seq(self.blocks, x)
1549 else:
-> 1550 x = self.blocks(x)
1551 return x
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
File /scratch/ahmed/lib/torch/nn/modules/container.py:215, in Sequential.forward(self, input)
213 def forward(self, input):
214 for module in self:
--> 215 input = module(input)
216 return input
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1440, in MaxxVitBlock.forward(self, x)
1438 if not self.nchw_attn:
1439 x = x.permute(0, 2, 3, 1) # to NHWC (channels-last)
-> 1440 x = self.attn_block(x)
1441 x = self.attn_grid(x)
1442 if not self.nchw_attn:
File /scratch/ahmed/lib/torch/nn/modules/module.py:1518, in Module._wrapped_call_impl(self, *args, **kwargs)
1516 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1517 else:
-> 1518 return self._call_impl(*args, **kwargs)
File /scratch/ahmed/lib/torch/nn/modules/module.py:1527, in Module._call_impl(self, *args, **kwargs)
1522 # If we don't have any hooks, we want to skip the rest of the logic in
1523 # this function, and just call forward.
1524 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1525 or _global_backward_pre_hooks or _global_backward_hooks
1526 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1527 return forward_call(*args, **kwargs)
1529 try:
1530 result = None
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1228, in PartitionAttentionCl.forward(self, x)
1227 def forward(self, x):
-> 1228 x = x + self.drop_path1(self.ls1(self._partition_attn(self.norm1(x))))
1229 x = x + self.drop_path2(self.ls2(self.mlp(self.norm2(x))))
1230 return x
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1215, in PartitionAttentionCl._partition_attn(self, x)
1213 img_size = x.shape[1:3]
1214 if self.partition_block:
-> 1215 partitioned = window_partition(x, self.partition_size)
1216 else:
1217 partitioned = grid_partition(x, self.partition_size)
File /scratch/ahmed/G-CASCADE-main/lib/maxxvit_4out.py:1127, in window_partition(x, window_size)
1125 def window_partition(x, window_size: List[int]):
1126 B, H, W, C = x.shape
-> 1127 _assert(H % window_size[0] == 0, f'height ({H}) must be divisible by window ({window_size[0]})')
1128 _assert(W % window_size[1] == 0, '')
1129 x = x.view(B, H // window_size[0], window_size[0], W // window_size[1], window_size[1], C)
File /scratch/ahmed/lib/torch/__init__.py:1404, in _assert(condition, message)
1402 if type(condition) is not torch.Tensor and has_torch_function((condition,)):
1403 return handle_torch_function(_assert, (condition,), condition, message)
-> 1404 assert condition, message
AssertionError: height (28) must be divisible by window (8)