@@ -92,7 +92,7 @@ def __init__(
9292 out_channels : int | None = None ,
9393 scale_factor : Sequence [float ] | float = 2 ,
9494 kernel_size : Sequence [float ] | float | None = None ,
95- mode : str = "conv" , # conv, convgroup, nontrainable, pixelunshuffle
95+ mode : DownsampleMode | str = DownsampleMode . CONV ,
9696 pre_conv : nn .Module | str | None = "default" ,
9797 post_conv : nn .Module | None = None ,
9898 bias : bool = True ,
@@ -101,11 +101,11 @@ def __init__(
101101 Downsamples data by `scale_factor`.
102102 Supported modes are:
103103
104- - "conv" : uses a strided convolution for learnable downsampling.
105- - "convgroup" : uses a grouped strided convolution for efficient feature reduction.
106- - "maxpool" : uses maxpooling for non-learnable downsampling.
107- - "avgpool" : uses average pooling for non-learnable downsampling.
108- - "pixelunshuffle" : uses :py:class:`monai.networks.blocks.SubpixelDownsample`.
104+ - DownsampleMode.CONV : uses a strided convolution for learnable downsampling.
105+ - DownsampleMode.CONVGROUP : uses a grouped strided convolution for efficient feature reduction.
106+ - DownsampleMode.MAXPOOL : uses maxpooling for non-learnable downsampling.
107+ - DownsampleMode.AVGPOOL : uses average pooling for non-learnable downsampling.
108+ - DownsampleMode.PIXELUNSHUFFLE : uses :py:class:`monai.networks.blocks.SubpixelDownsample`.
109109
110110 This operation will cause non-deterministic behavior when ``mode`` is ``DownsampleMode.NONTRAINABLE``.
111111 Please check the link below for more details:
@@ -120,7 +120,8 @@ def __init__(
120120 out_channels: number of channels of the output image. Defaults to `in_channels`.
121121 scale_factor: multiplier for spatial size reduction. Has to match input size if it is a tuple. Defaults to 2.
122122 kernel_size: kernel size used during convolutions. Defaults to `scale_factor`.
123- mode: {``"conv"``, ``"convgroup"``, ``"maxpool"``, ``"avgpool"``, ``"pixelunshuffle"``}. Defaults to ``"conv"``.
123+ mode: {``DownsampleMode.CONV``, ``DownsampleMode.CONVGROUP``, ``DownsampleMode.MAXPOOL``, ``DownsampleMode.AVGPOOL``,
124+ ``DownsampleMode.PIXELUNSHUFFLE``}. Defaults to ``DownsampleMode.CONV``.
124125 pre_conv: a conv block applied before downsampling. Defaults to "default".
125126 When ``conv_block`` is ``"default"``, one reserved conv layer will be utilized.
126127 Only used in the "maxpool", "avgpool" or "pixelunshuffle" modes.
@@ -134,7 +135,7 @@ def __init__(
134135
135136 if not kernel_size :
136137 kernel_size_ = scale_factor_
137- padding = 0
138+ padding = ensure_tuple_rep ( 0 , spatial_dims )
138139 else :
139140 kernel_size_ = ensure_tuple_rep (kernel_size , spatial_dims )
140141 padding = tuple ((k - 1 ) // 2 for k in kernel_size_ )
0 commit comments