From 5a644e4edcc37e5c963e52fda6fab4c85b3ff02e Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:07:11 +0800 Subject: [PATCH] Fix unused `kernel_size` in `ResBlock` (#6999) Fixes #6998 ### Description Fixed unused `kernel_size` in `ResBlock`. Fixed untested `norm` in unit tests. ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [x] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: KumoLiu --- monai/networks/blocks/segresnet_block.py | 8 ++++++-- tests/test_segresnet_block.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monai/networks/blocks/segresnet_block.py b/monai/networks/blocks/segresnet_block.py index 3337f50043..370abffe89 100644 --- a/monai/networks/blocks/segresnet_block.py +++ b/monai/networks/blocks/segresnet_block.py @@ -73,8 +73,12 @@ def __init__( self.norm1 = get_norm_layer(name=norm, spatial_dims=spatial_dims, channels=in_channels) self.norm2 = get_norm_layer(name=norm, spatial_dims=spatial_dims, channels=in_channels) self.act = get_act_layer(act) - self.conv1 = get_conv_layer(spatial_dims, in_channels=in_channels, out_channels=in_channels) - self.conv2 = get_conv_layer(spatial_dims, in_channels=in_channels, out_channels=in_channels) + self.conv1 = get_conv_layer( + spatial_dims, in_channels=in_channels, out_channels=in_channels, kernel_size=kernel_size + ) + self.conv2 = get_conv_layer( + spatial_dims, in_channels=in_channels, out_channels=in_channels, kernel_size=kernel_size + ) def forward(self, x): identity = x diff --git a/tests/test_segresnet_block.py b/tests/test_segresnet_block.py index dd455aec13..343f39d72c 100644 --- a/tests/test_segresnet_block.py +++ b/tests/test_segresnet_block.py @@ -23,7 +23,7 @@ for spatial_dims in range(2, 4): for in_channels in range(1, 4): for kernel_size in [1, 3]: - for norm in ["group", "batch", "instance"]: + for norm in [("group", {"num_groups": 1}), "batch", "instance"]: test_case = [ { "spatial_dims": spatial_dims, @@ -34,7 +34,7 @@ (2, in_channels, *([16] * spatial_dims)), (2, in_channels, *([16] * spatial_dims)), ] - TEST_CASE_RESBLOCK.append(test_case) + TEST_CASE_RESBLOCK.append(test_case) class TestResBlock(unittest.TestCase):