deepali.networks.unet
#
U-net model architectures.
Module Contents#
Classes#
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Base class of configuration data classes. |
|
Downsampling path of U-net model. |
|
Upsampling path of U-net model. |
|
Sequential U-net architecture. |
|
U-net with optionally multiple output layers. |
Functions#
|
Create U-net block of convolutional layers. |
- class UNetEncoderConfig[source]#
-
Base class of configuration data classes.
- property num_levels: int#
Number of spatial encoder levels.
- class UNetDecoderConfig[source]#
-
Base class of configuration data classes.
- property num_levels: int#
Number of spatial decoder levels, including bottleneck input.
- classmethod from_encoder(encoder: Union[UNetEncoder, UNetEncoderConfig], residual: Optional[bool] = None, **kwargs) UNetDecoderConfig [source]#
Derive decoder configuration from U-net encoder configuration.
- unet_conv_block(spatial_dims: int, in_channels: int, out_channels: int, kernel_size: deepali.core.typing.ScalarOrTuple[int] = 3, stride: deepali.core.typing.ScalarOrTuple[int] = 1, padding: Optional[deepali.core.typing.ScalarOrTuple[int]] = None, padding_mode: Union[deepali.core.enum.PaddingMode, str] = 'zeros', dilation: deepali.core.typing.ScalarOrTuple[int] = 1, groups: int = 1, init: str = 'default', bias: Optional[Union[bool, str]] = None, norm: deepali.networks.layers.NormArg = None, acti: deepali.networks.layers.ActivationArg = None, order: str = 'CNA', num_layers: Optional[int] = None) torch.nn.Module [source]#
Create U-net block of convolutional layers.
- class UNetEncoder(spatial_dims: int, in_channels: Optional[int] = None, config: Optional[UNetEncoderConfig] = None, conv_block: Optional[ModuleFactory] = None, input_layer: Optional[ModuleFactory] = None)[source]#
-
Downsampling path of U-net model.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- class UNetDecoder(spatial_dims: int, in_channels: Optional[int] = None, config: Optional[UNetDecoderConfig] = None, conv_block: Optional[ModuleFactory] = None, input_layer: Optional[ModuleFactory] = None, output_all: bool = False)[source]#
-
Upsampling path of U-net model.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- classmethod from_encoder(encoder: Union[UNetEncoder, UNetEncoderConfig], residual: Optional[bool] = None, **kwargs) UNetDecoder [source]#
Create U-net decoder given U-net encoder configuration.
- class SequentialUNet(spatial_dims: int, in_channels: Optional[int] = None, out_channels: Optional[int] = None, config: Optional[UNetConfig] = None, conv_block: Optional[ModuleFactory] = None, output_layer: Optional[ModuleFactory] = None, bridge_layer: Optional[ModuleFactory] = None)[source]#
-
Sequential U-net architecture.
The final module of this sequential module either outputs a tuple of feature maps at the different resolution levels (
out_channels=None
), the final decoded feature map at the highest resolution level (out_channels == config.decoder.out_channels
andoutput_layers=None
), or a tensor with specified number ofout_channels
as produced by a final output layer otherwise. Note that additional layers (e.g., a custom output layer or post-output layers) can be added to the initialized sequential U-net usingadd_module()
.Initializes internal Module state, shared by both nn.Module and ScriptModule.
- class UNet(spatial_dims: int, in_channels: Optional[int] = None, out_channels: Optional[int] = None, output_modules: Optional[Mapping[str, torch.nn.Module]] = None, output_indices: Optional[Union[Mapping[str, int], int]] = None, config: Optional[UNetConfig] = None, conv_block: Optional[ModuleFactory] = None, bridge_layer: Optional[ModuleFactory] = None, output_layer: Optional[ModuleFactory] = None, output_name: str = 'output')[source]#
-
U-net with optionally multiple output layers.
Initializes internal Module state, shared by both nn.Module and ScriptModule.