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

Fix constructors for DenseNet derived classes #5846

Merged
merged 5 commits into from
Jan 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions monai/networks/nets/densenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,17 @@ class DenseNet121(DenseNet):

def __init__(
self,
spatial_dims: int,
in_channels: int,
out_channels: int,
init_features: int = 64,
growth_rate: int = 32,
block_config: Sequence[int] = (6, 12, 24, 16),
pretrained: bool = False,
progress: bool = True,
**kwargs,
) -> None:
super().__init__(init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
super().__init__(spatial_dims=spatial_dims, in_channels=in_channels, out_channels=out_channels, init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
if pretrained:
if kwargs["spatial_dims"] > 2:
wyli marked this conversation as resolved.
Show resolved Hide resolved
wyli marked this conversation as resolved.
Show resolved Hide resolved
raise NotImplementedError(
Expand All @@ -318,14 +321,17 @@ class DenseNet169(DenseNet):

def __init__(
self,
spatial_dims: int,
in_channels: int,
out_channels: int,
init_features: int = 64,
growth_rate: int = 32,
block_config: Sequence[int] = (6, 12, 32, 32),
pretrained: bool = False,
progress: bool = True,
**kwargs,
) -> None:
super().__init__(init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
super().__init__(spatial_dims=spatial_dims, in_channels=in_channels, out_channels=out_channels, init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
if pretrained:
if kwargs["spatial_dims"] > 2:
wyli marked this conversation as resolved.
Show resolved Hide resolved
raise NotImplementedError(
Expand All @@ -340,14 +346,17 @@ class DenseNet201(DenseNet):

def __init__(
self,
spatial_dims: int,
in_channels: int,
out_channels: int,
init_features: int = 64,
growth_rate: int = 32,
block_config: Sequence[int] = (6, 12, 48, 32),
pretrained: bool = False,
progress: bool = True,
**kwargs,
) -> None:
super().__init__(init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
super().__init__(spatial_dims=spatial_dims, in_channels=in_channels, out_channels=out_channels, init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
if pretrained:
if kwargs["spatial_dims"] > 2:
wyli marked this conversation as resolved.
Show resolved Hide resolved
raise NotImplementedError(
Expand All @@ -362,14 +371,17 @@ class DenseNet264(DenseNet):

def __init__(
self,
spatial_dims: int,
in_channels: int,
out_channels: int,
init_features: int = 64,
growth_rate: int = 32,
block_config: Sequence[int] = (6, 12, 64, 48),
pretrained: bool = False,
progress: bool = True,
**kwargs,
) -> None:
super().__init__(init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
super().__init__(spatial_dims=spatial_dims, in_channels=in_channels, out_channels=out_channels, init_features=init_features, growth_rate=growth_rate, block_config=block_config, **kwargs)
if pretrained:
raise NotImplementedError("Currently PyTorch Hub does not provide densenet264 pretrained models.")

Expand Down