From eee75b10ec9db2b7ee865ca6ab29562667f814ff Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:25:42 +0800 Subject: [PATCH 1/2] fix #8248 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/networks/nets/swin_unetr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/networks/nets/swin_unetr.py b/monai/networks/nets/swin_unetr.py index 32b817d584..77f0d2ec2f 100644 --- a/monai/networks/nets/swin_unetr.py +++ b/monai/networks/nets/swin_unetr.py @@ -75,7 +75,7 @@ def __init__( dropout_path_rate: float = 0.0, normalize: bool = True, norm_layer: type[LayerNorm] = nn.LayerNorm, - patch_norm: bool = True, + patch_norm: bool = False, use_checkpoint: bool = False, spatial_dims: int = 3, downsample: str | nn.Module = "merging", @@ -102,7 +102,7 @@ def __init__( dropout_path_rate: drop path rate. normalize: normalize output intermediate features in each stage. norm_layer: normalization layer. - patch_norm: whether to apply normalization to the patch embedding. + patch_norm: whether to apply normalization to the patch embedding. Default is False. use_checkpoint: use gradient checkpointing for reduced memory usage. spatial_dims: number of spatial dims. downsample: module used for downsampling, available options are `"mergingv2"`, `"merging"` and a From a3d091778c9190968711b576797fedca67528dc6 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:10:19 +0800 Subject: [PATCH 2/2] fix #8251 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/networks/blocks/pos_embed_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/networks/blocks/pos_embed_utils.py b/monai/networks/blocks/pos_embed_utils.py index 21586e56da..a9c5176bc2 100644 --- a/monai/networks/blocks/pos_embed_utils.py +++ b/monai/networks/blocks/pos_embed_utils.py @@ -56,7 +56,7 @@ def build_sincos_position_embedding( grid_h = torch.arange(h, dtype=torch.float32) grid_w = torch.arange(w, dtype=torch.float32) - grid_h, grid_w = torch.meshgrid(grid_h, grid_w, indexing="ij") + grid_h, grid_w = torch.meshgrid(grid_h, grid_w) if embed_dim % 4 != 0: raise AssertionError("Embed dimension must be divisible by 4 for 2D sin-cos position embedding") @@ -75,7 +75,7 @@ def build_sincos_position_embedding( grid_w = torch.arange(w, dtype=torch.float32) grid_d = torch.arange(d, dtype=torch.float32) - grid_h, grid_w, grid_d = torch.meshgrid(grid_h, grid_w, grid_d, indexing="ij") + grid_h, grid_w, grid_d = torch.meshgrid(grid_h, grid_w, grid_d) if embed_dim % 6 != 0: raise AssertionError("Embed dimension must be divisible by 6 for 3D sin-cos position embedding")