SegResEncoder based on the encoder structure in `3D MRI brain tumor segmentation using autoencoder regularization `_. Args: spatial_dims: spatial dimension of the input data. Defaults to 3. init_filters: number of output channels fo
| 125 | |
| 126 | |
| 127 | class SegResEncoder(nn.Module): |
| 128 | """ |
| 129 | SegResEncoder based on the encoder structure in `3D MRI brain tumor segmentation using autoencoder regularization |
| 130 | <https://arxiv.org/pdf/1810.11654.pdf>`_. |
| 131 | |
| 132 | Args: |
| 133 | spatial_dims: spatial dimension of the input data. Defaults to 3. |
| 134 | init_filters: number of output channels for initial convolution layer. Defaults to 32. |
| 135 | in_channels: number of input channels for the network. Defaults to 1. |
| 136 | out_channels: number of output channels for the network. Defaults to 2. |
| 137 | act: activation type and arguments. Defaults to ``RELU``. |
| 138 | norm: feature normalization type and arguments. Defaults to ``BATCH``. |
| 139 | blocks_down: number of downsample blocks in each layer. Defaults to ``[1,2,2,4]``. |
| 140 | head_module: optional callable module to apply to the final features. |
| 141 | anisotropic_scales: optional list of scale for each scale level. |
| 142 | """ |
| 143 | |
| 144 | def __init__( |
| 145 | self, |
| 146 | spatial_dims: int = 3, |
| 147 | init_filters: int = 32, |
| 148 | in_channels: int = 1, |
| 149 | act: tuple | str = "relu", |
| 150 | norm: tuple | str = "batch", |
| 151 | blocks_down: tuple = (1, 2, 2, 4), |
| 152 | head_module: nn.Module | None = None, |
| 153 | anisotropic_scales: tuple | None = None, |
| 154 | ): |
| 155 | super().__init__() |
| 156 | |
| 157 | if spatial_dims not in (1, 2, 3): |
| 158 | raise ValueError("`spatial_dims` can only be 1, 2 or 3.") |
| 159 | |
| 160 | # ensure normalization has affine trainable parameters (if not specified) |
| 161 | norm = split_args(norm) |
| 162 | if has_option(Norm[norm[0], spatial_dims], "affine"): |
| 163 | norm[1].setdefault("affine", True) # type: ignore |
| 164 | |
| 165 | # ensure activation is inplace (if not specified) |
| 166 | act = split_args(act) |
| 167 | if has_option(Act[act[0]], "inplace"): |
| 168 | act[1].setdefault("inplace", True) # type: ignore |
| 169 | |
| 170 | filters = init_filters # base number of features |
| 171 | |
| 172 | kernel_size, padding, _ = aniso_kernel(anisotropic_scales[0]) if anisotropic_scales else (3, 1, 1) |
| 173 | self.conv_init = Conv[Conv.CONV, spatial_dims]( |
| 174 | in_channels=in_channels, |
| 175 | out_channels=filters, |
| 176 | kernel_size=kernel_size, |
| 177 | padding=padding, |
| 178 | stride=1, |
| 179 | bias=False, |
| 180 | ) |
| 181 | self.layers = nn.ModuleList() |
| 182 | |
| 183 | for i in range(len(blocks_down)): |
| 184 | level = nn.ModuleDict() |
no outgoing calls
no test coverage detected
searching dependent graphs…