diff --git a/monai/networks/blocks/convolutions.py b/monai/networks/blocks/convolutions.py index 8b18614364..bbd49e509a 100644 --- a/monai/networks/blocks/convolutions.py +++ b/monai/networks/blocks/convolutions.py @@ -231,7 +231,7 @@ class ResidualUnit(nn.Module): - When dropout_dim = 2, Randomly zero out entire channels (a channel is a 2D feature map). - When dropout_dim = 3, Randomly zero out entire channels (a channel is a 3D feature map). - The value of dropout_dim should be no larger than the value of `dimensions`. + The value of dropout_dim should be no larger than the value of `spatial_dims`. dilation: dilation rate. Defaults to 1. bias: whether to have a bias term. Defaults to True. last_conv_only: for the last subunit, whether to use the convolutional layer only. @@ -269,7 +269,7 @@ def __init__( self.out_channels = out_channels self.conv = nn.Sequential() self.residual = nn.Identity() - if not padding: + if padding is None: padding = same_padding(kernel_size, dilation) schannels = in_channels sstrides = strides diff --git a/tests/networks/blocks/test_convolutions.py b/tests/networks/blocks/test_convolutions.py index f882f133e9..0bbb8fa0ab 100644 --- a/tests/networks/blocks/test_convolutions.py +++ b/tests/networks/blocks/test_convolutions.py @@ -151,6 +151,10 @@ def test_dropout1(self): expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1]) self.assertEqual(out.shape, expected_shape) + def test_padding1(self): + conv = ResidualUnit(2, 1, self.output_channels, kernel_size=1, padding=0) + self.assertEqual(conv.conv.unit0.conv.padding, (0, 0)) + if __name__ == "__main__": unittest.main()