Skip to content

Attention-UNet implementation does not propagate kernel_size #7726

@Serpaija

Description

@Serpaija

Description
When changing the kernel_size of the attention-unet, amount of trainable parameters stays the same.
Reason: The kernel size will be set to the assigned default value, because the when creating ConvBlocks the Kernelsize is not propagated.

To Reproduce
Steps to reproduce the behavior:

  1. Create a model "Attention Unet" from monai.networks.nets
from monai.networks.nets import AttentionUnet

model = AttentionUnet(
        spatial_dims = 2,
        in_channels = 1,
        out_channels = 1,
        channels = (2, 4, 8, 16),
        strides = (2,2,2),
        kernel_size = 5,
        up_kernel_size = 5
)
  1. Run command
from torchinfo import summary

summary(model, (1,1,16,16))

Expected behavior

Total params: 18,846
Trainable params: 18,846
Non-trainable params: 0
Total mult-adds (M): 0.37

Actual behavior

Total params: 10,686
Trainable params: 10,686
Non-trainable params: 0
Total mult-adds (M): 0.27

Environment

python -c "import monai; monai.config.print_debug_info()"

MONAI version: 1.3.0
Numpy version: 1.24.4
Pytorch version: 1.9.0+cu111
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 865972f7a791bf7b42efbcd87c8402bd865b329e
MONAI __file__: /opt/conda/lib/python3.8/site-packages/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: 0.4.11
ITK version: 5.3.0
Nibabel version: 5.2.1
scikit-image version: 0.18.1
scipy version: 1.10.1
Pillow version: 8.2.0
Tensorboard version: 2.5.0
gdown version: 4.7.3
TorchVision version: 0.10.0+cu111
tqdm version: 4.61.1
lmdb version: 1.2.1
psutil version: 5.8.0
pandas version: 1.2.5
einops version: 0.3.0
transformers version: 4.8.1
mlflow version: 2.12.1
pynrrd version: 1.0.0
clearml version: 1.15.1

Additional remarks
This behaviour might occur for other network architectures aswell.
Please review this issue for similar architectures (I have not checked this myself).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions