MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/networks/nets/segresnet.py:59–101  ·  view source on GitHub ↗
(
        self,
        spatial_dims: int = 3,
        init_filters: int = 8,
        in_channels: int = 1,
        out_channels: int = 2,
        dropout_prob: float | None = None,
        act: tuple | str = ("RELU", {"inplace": True}),
        norm: tuple | str = ("GROUP", {"num_groups": 8}),
        norm_name: str = "",
        num_groups: int = 8,
        use_conv_final: bool = True,
        blocks_down: tuple = (1, 2, 2, 4),
        blocks_up: tuple = (1, 1, 1),
        upsample_mode: UpsampleMode | str = UpsampleMode.NONTRAINABLE,
    )

Source from the content-addressed store, hash-verified

57 """
58
59 def __init__(
60 self,
61 spatial_dims: int = 3,
62 init_filters: int = 8,
63 in_channels: int = 1,
64 out_channels: int = 2,
65 dropout_prob: float | None = None,
66 act: tuple | str = ("RELU", {"inplace": True}),
67 norm: tuple | str = ("GROUP", {"num_groups": 8}),
68 norm_name: str = "",
69 num_groups: int = 8,
70 use_conv_final: bool = True,
71 blocks_down: tuple = (1, 2, 2, 4),
72 blocks_up: tuple = (1, 1, 1),
73 upsample_mode: UpsampleMode | str = UpsampleMode.NONTRAINABLE,
74 ):
75 super().__init__()
76
77 if spatial_dims not in (2, 3):
78 raise ValueError("`spatial_dims` can only be 2 or 3.")
79
80 self.spatial_dims = spatial_dims
81 self.init_filters = init_filters
82 self.in_channels = in_channels
83 self.blocks_down = blocks_down
84 self.blocks_up = blocks_up
85 self.dropout_prob = dropout_prob
86 self.act = act # input options
87 self.act_mod = get_act_layer(act)
88 if norm_name:
89 if norm_name.lower() != "group":
90 raise ValueError(f"Deprecating option 'norm_name={norm_name}', please use 'norm' instead.")
91 norm = ("group", {"num_groups": num_groups})
92 self.norm = norm
93 self.upsample_mode = UpsampleMode(upsample_mode)
94 self.use_conv_final = use_conv_final
95 self.convInit = get_conv_layer(spatial_dims, in_channels, init_filters)
96 self.down_layers = self._make_down_layers()
97 self.up_layers, self.up_samples = self._make_up_layers()
98 self.conv_final = self._make_final_conv(out_channels)
99
100 if dropout_prob is not None:
101 self.dropout = Dropout[Dropout.DROPOUT, spatial_dims](dropout_prob)
102
103 def _make_down_layers(self):
104 down_layers = nn.ModuleList()

Callers 1

__init__Method · 0.45

Calls 6

_make_down_layersMethod · 0.95
_make_up_layersMethod · 0.95
_make_final_convMethod · 0.95
get_act_layerFunction · 0.90
UpsampleModeClass · 0.90
get_conv_layerFunction · 0.90

Tested by

no test coverage detected