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

Method __init__

monai/networks/nets/segresnet_ds.py:273–385  ·  view source on GitHub ↗
(
        self,
        spatial_dims: int = 3,
        init_filters: int = 32,
        in_channels: int = 1,
        out_channels: int = 2,
        act: tuple | str = "relu",
        norm: tuple | str = "batch",
        blocks_down: tuple = (1, 2, 2, 4),
        blocks_up: tuple | None = None,
        dsdepth: int = 1,
        preprocess: nn.Module | Callable | None = None,
        upsample_mode: UpsampleMode | str = "deconv",
        resolution: tuple | None = None,
    )

Source from the content-addressed store, hash-verified

271 """
272
273 def __init__(
274 self,
275 spatial_dims: int = 3,
276 init_filters: int = 32,
277 in_channels: int = 1,
278 out_channels: int = 2,
279 act: tuple | str = "relu",
280 norm: tuple | str = "batch",
281 blocks_down: tuple = (1, 2, 2, 4),
282 blocks_up: tuple | None = None,
283 dsdepth: int = 1,
284 preprocess: nn.Module | Callable | None = None,
285 upsample_mode: UpsampleMode | str = "deconv",
286 resolution: tuple | None = None,
287 ):
288 super().__init__()
289
290 if spatial_dims not in (1, 2, 3):
291 raise ValueError("`spatial_dims` can only be 1, 2 or 3.")
292
293 self.spatial_dims = spatial_dims
294 self.init_filters = init_filters
295 self.in_channels = in_channels
296 self.out_channels = out_channels
297 self.act = act
298 self.norm = norm
299 self.blocks_down = blocks_down
300 self.dsdepth = max(dsdepth, 1)
301 self.resolution = resolution
302 self.preprocess = preprocess
303
304 if resolution is not None:
305 if not isinstance(resolution, (list, tuple)):
306 raise TypeError("resolution must be a tuple")
307 elif not all(r > 0 for r in resolution):
308 raise ValueError("resolution must be positive")
309
310 # ensure normalization had affine trainable parameters (if not specified)
311 norm = split_args(norm)
312 if has_option(Norm[norm[0], spatial_dims], "affine"):
313 norm[1].setdefault("affine", True) # type: ignore
314
315 # ensure activation is inplace (if not specified)
316 act = split_args(act)
317 if has_option(Act[act[0]], "inplace"):
318 act[1].setdefault("inplace", True) # type: ignore
319
320 anisotropic_scales = None
321 if resolution:
322 anisotropic_scales = scales_for_resolution(resolution, n_stages=len(blocks_down))
323 self.anisotropic_scales = anisotropic_scales
324
325 self.encoder = SegResEncoder(
326 spatial_dims=spatial_dims,
327 init_filters=init_filters,
328 in_channels=in_channels,
329 act=act,
330 norm=norm,

Callers

nothing calls this directly

Calls 10

split_argsFunction · 0.90
has_optionFunction · 0.90
UpSampleClass · 0.90
maxFunction · 0.85
scales_for_resolutionFunction · 0.85
SegResEncoderClass · 0.85
aniso_kernelFunction · 0.85
SegResBlockClass · 0.85
__init__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected