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

Method __init__

monai/networks/nets/flexible_unet.py:113–158  ·  view source on GitHub ↗
(
        self,
        spatial_dims: int,
        encoder_channels: Sequence[int],
        decoder_channels: Sequence[int],
        act: str | tuple,
        norm: str | tuple,
        dropout: float | tuple,
        bias: bool,
        upsample: str,
        pre_conv: str | None,
        interp_mode: str,
        align_corners: bool | None,
        is_pad: bool,
    )

Source from the content-addressed store, hash-verified

111 """
112
113 def __init__(
114 self,
115 spatial_dims: int,
116 encoder_channels: Sequence[int],
117 decoder_channels: Sequence[int],
118 act: str | tuple,
119 norm: str | tuple,
120 dropout: float | tuple,
121 bias: bool,
122 upsample: str,
123 pre_conv: str | None,
124 interp_mode: str,
125 align_corners: bool | None,
126 is_pad: bool,
127 ):
128 super().__init__()
129 if len(encoder_channels) < 2:
130 raise ValueError("the length of `encoder_channels` should be no less than 2.")
131 if len(decoder_channels) != len(encoder_channels) - 1:
132 raise ValueError("`len(decoder_channels)` should equal to `len(encoder_channels) - 1`.")
133
134 in_channels = [encoder_channels[-1]] + list(decoder_channels[:-1])
135 skip_channels = list(encoder_channels[1:-1][::-1]) + [0]
136 halves = [True] * (len(skip_channels) - 1)
137 halves.append(False)
138 blocks = []
139 for in_chn, skip_chn, out_chn, halve in zip(in_channels, skip_channels, decoder_channels, halves):
140 blocks.append(
141 UpCat(
142 spatial_dims=spatial_dims,
143 in_chns=in_chn,
144 cat_chns=skip_chn,
145 out_chns=out_chn,
146 act=act,
147 norm=norm,
148 dropout=dropout,
149 bias=bias,
150 upsample=upsample,
151 pre_conv=pre_conv,
152 interp_mode=interp_mode,
153 align_corners=align_corners,
154 halves=halve,
155 is_pad=is_pad,
156 )
157 )
158 self.blocks = nn.ModuleList(blocks)
159
160 def forward(self, features: list[torch.Tensor], skip_connect: int = 4):
161 skips = features[:-1][::-1]

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

UpCatClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected