Skip to content

Commit 5c9c7b0

Browse files
Change default upsample_mode for ANHet (#1028)
Signed-off-by: yiheng-wang-nv <[email protected]>
1 parent e6ac8bf commit 5c9c7b0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

monai/networks/nets/ahnet.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,17 @@ class AHNet(nn.Module):
332332
"""
333333
AHNet based on `Anisotropic Hybrid Network <https://arxiv.org/pdf/1711.08580.pdf>`_.
334334
Adapted from `lsqshr's official code <https://github.com/lsqshr/AH-Net/blob/master/net3d.py>`_.
335-
The model supports 2D or 3D inputs, as for the original 3D version.
335+
Except from the original network that supports 3D inputs, this implementation also supports 2D inputs.
336+
According to the `tests for deconvolutions <https://github.com/Project-MONAI/MONAI/issues/1023>`_, using
337+
``"transpose"`` rather than linear interpolations is faster. Therefore, this implementation sets ``"transpose"``
338+
as the default upsampling method.
339+
336340
To meet to requirements of the structure, the input size of the first ``dim-1`` dimensions should be divisible
337-
by 32 and no less than 128. If you need to use lower sizes, please reduce the largest blocks in PSP
338-
module and change the ``num_input_features`` in Final module.
339-
In addition, to utilize the "transpose" upsample mode, please ensure that the input size of the first ``dim-1`` dimensions
340-
should be divisible by 128. In order to use pretrained weights from 2D FCN/MCFCN, please call the `copy_from` function,
341+
by 128. In addition, for linear interpolation based upsampling modes, the input size of the first ``dim-1``
342+
dimensions should be divisible by 32 and no less than 128. If you need to use lower sizes, please reduce the
343+
largest blocks in PSP module and change the ``num_input_features`` in Final module.
344+
345+
In order to use pretrained weights from 2D FCN/MCFCN, please call the `copy_from` function,
341346
for example:
342347
343348
.. code-block:: python
@@ -352,7 +357,7 @@ class AHNet(nn.Module):
352357
out_channels: number of output channels for the network. Defaults to 1.
353358
upsample_mode: [``"transpose"``, ``"bilinear"``, ``"trilinear"``]
354359
The mode of upsampling manipulations.
355-
Using the last two modes cannot guarantee the model's reproducibility. Defaults to ``trilinear``.
360+
Using the last two modes cannot guarantee the model's reproducibility. Defaults to ``transpose``.
356361
357362
- ``"transpose"``, uses transposed convolution layers.
358363
- ``"bilinear"``, uses bilinear interpolate.
@@ -364,7 +369,7 @@ def __init__(
364369
layers: tuple = (3, 4, 6, 3),
365370
spatial_dims: int = 3,
366371
out_channels: int = 1,
367-
upsample_mode: str = "trilinear",
372+
upsample_mode: str = "transpose",
368373
):
369374
self.inplanes = 64
370375
super(AHNet, self).__init__()

0 commit comments

Comments
 (0)