Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate kernel size through attention Attention-UNet #7734

Merged
merged 6 commits into from
May 7, 2024

Conversation

Pkaps25
Copy link
Contributor

@Pkaps25 Pkaps25 commented May 1, 2024

Fixes #7726.

Description

Passes the kernel_size parameter to ConvBlocks within Attention UNet, creating a net with the expected number of parameters.

Using the example in #7726 on this branch:

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
)

outputs the expected values:

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

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • 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.

Peter Kaplinsky added 2 commits May 1, 2024 12:18
Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
@Pkaps25 Pkaps25 changed the title Propagate kernel size through attention unet convblocks Propagate kernel size through attention Attention-UNet May 1, 2024
Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
@Pkaps25 Pkaps25 marked this pull request as ready for review May 1, 2024 23:13
@Pkaps25
Copy link
Contributor Author

Pkaps25 commented May 1, 2024

@KumoLiu ready for review

@ericspod
Copy link
Member

ericspod commented May 2, 2024

Hi @Pkaps25 I see that this only changes the internal code by propagating the kernel size value, so this should not affect existing code or saved weights since the default everywhere was 3 and still is. Could you please add some tests which create instances of the network with different kernel values and checks the number of parameters changes? We should ensure this behaviour is captured in the tests which, since they pass, all use only the default value of 3. Thanks!

Peter Kaplinsky added 2 commits May 2, 2024 14:23
Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
@Pkaps25
Copy link
Contributor Author

Pkaps25 commented May 2, 2024

Hi @Pkaps25 I see that this only changes the internal code by propagating the kernel size value, so this should not affect existing code or saved weights since the default everywhere was 3 and still is. Could you please add some tests which create instances of the network with different kernel values and checks the number of parameters changes? We should ensure this behaviour is captured in the tests which, since they pass, all use only the default value of 3. Thanks!

Done!

Signed-off-by: Peter Kaplinsky <peterkaplinsky@gmail.com>
Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, overall looks good to me.

@KumoLiu KumoLiu requested a review from ericspod May 6, 2024 07:45
@KumoLiu
Copy link
Contributor

KumoLiu commented May 6, 2024

/build

2 similar comments
@KumoLiu
Copy link
Contributor

KumoLiu commented May 6, 2024

/build

@KumoLiu
Copy link
Contributor

KumoLiu commented May 6, 2024

/build

@KumoLiu KumoLiu merged commit fe733b0 into Project-MONAI:dev May 7, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attention-UNet implementation does not propagate kernel_size
3 participants