Args: decode_config: number of layers for each block. act: activation type and arguments. Defaults to relu. norm: feature normalization type and arguments. Defaults to batch norm. dropout_prob: dropout rate after each dense layer.
(
self,
decode_config: Sequence[int] = (8, 4),
act: str | tuple = ("relu", {"inplace": True}),
norm: str | tuple = "batch",
dropout_prob: float = 0.0,
out_channels: int = 2,
kernel_size: int = 3,
same_padding: bool = False,
)
| 319 | class _DecoderBranch(nn.ModuleList): |
| 320 | |
| 321 | def __init__( |
| 322 | self, |
| 323 | decode_config: Sequence[int] = (8, 4), |
| 324 | act: str | tuple = ("relu", {"inplace": True}), |
| 325 | norm: str | tuple = "batch", |
| 326 | dropout_prob: float = 0.0, |
| 327 | out_channels: int = 2, |
| 328 | kernel_size: int = 3, |
| 329 | same_padding: bool = False, |
| 330 | ) -> None: |
| 331 | """ |
| 332 | Args: |
| 333 | decode_config: number of layers for each block. |
| 334 | act: activation type and arguments. Defaults to relu. |
| 335 | norm: feature normalization type and arguments. Defaults to batch norm. |
| 336 | dropout_prob: dropout rate after each dense layer. |
| 337 | out_channels: number of the output channel. |
| 338 | kernel_size: size of the kernel for >1 convolutions (dependent on mode) |
| 339 | same_padding: whether to do padding for >1 convolutions to ensure |
| 340 | the output size is the same as the input size. |
| 341 | """ |
| 342 | super().__init__() |
| 343 | conv_type: Callable = Conv[Conv.CONV, 2] |
| 344 | |
| 345 | # decode branches |
| 346 | _in_channels = 1024 |
| 347 | _num_features = 128 |
| 348 | _out_channels = 32 |
| 349 | |
| 350 | self.decoder_blocks = nn.Sequential() |
| 351 | for i, num_layers in enumerate(decode_config): |
| 352 | block = _DecoderBlock( |
| 353 | layers=num_layers, |
| 354 | num_features=_num_features, |
| 355 | in_channels=_in_channels, |
| 356 | out_channels=_out_channels, |
| 357 | dropout_prob=dropout_prob, |
| 358 | act=act, |
| 359 | norm=norm, |
| 360 | kernel_size=kernel_size, |
| 361 | same_padding=same_padding, |
| 362 | ) |
| 363 | self.decoder_blocks.add_module(f"decoderblock{i + 1}", block) |
| 364 | _in_channels = 512 |
| 365 | |
| 366 | # output layers |
| 367 | self.output_features = nn.Sequential() |
| 368 | _i = len(decode_config) |
| 369 | _pad_size = (kernel_size - 1) // 2 |
| 370 | _seq_block = nn.Sequential( |
| 371 | OrderedDict( |
| 372 | [("conva", conv_type(256, 64, kernel_size=kernel_size, stride=1, bias=False, padding=_pad_size))] |
| 373 | ) |
| 374 | ) |
| 375 | |
| 376 | self.output_features.add_module(f"decoderblock{_i + 1}", _seq_block) |
| 377 | |
| 378 | _seq_block = nn.Sequential( |
nothing calls this directly
no test coverage detected