(
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,
)
| 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, |
nothing calls this directly
no test coverage detected