Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Layer norm not working in densenet #7293

Closed
MiguelMonteiro opened this issue Dec 6, 2023 · 1 comment
Closed

Layer norm not working in densenet #7293

MiguelMonteiro opened this issue Dec 6, 2023 · 1 comment

Comments

@MiguelMonteiro
Copy link

Describe the bug
Layer norm does not work with densenet, returns the following error when instantiating model:

TypeError: LayerNorm.__init__() missing 1 required positional argument: 'normalized_shape'

To Reproduce

from monai.networks.nets.densenet import densenet121
model = densenet121(spatial_dims=3, in_channels=1, out_channels=2048, norm="layer")

Expected behavior
It should work or not be an option.

Environment

Python 3.10, pytorch 2.0.1, monai 1.3.0

Additional context
Bug has previously been reported here Project-MONAI/research-contributions#196

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 21, 2024

Hi @MiguelMonteiro, @K-Rilla, I re-checked the issue and found that norm can accept a tuple as input that contains the parameters needed by the matching norm layer.
You can do something like this:

from monai.networks.nets.densenet import DenseNet121
model = DenseNet121(spatial_dims=3, in_channels=1, out_channels=2048, norm=("layer", {"normalized_shape": [c, h, d]}))

Convert it to discussion, feel free to create another issue if meet further issue. Thanks.

@Project-MONAI Project-MONAI locked and limited conversation to collaborators Aug 21, 2024
@KumoLiu KumoLiu converted this issue into discussion #8035 Aug 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants