class EncodingBlock[source]

EncodingBlock(in_channels:int, out_channels_first:int, dimensions:int, normalization:str, pooling_type:str, pooling_kernel_size:int, preactivation:bool=False, is_first_block:bool=False, residual:bool=False, use_padding:bool=False, padding_mode:str='zeros', activation:str='ReLU', dilation:int=None, dropout:float=0.0) :: Module

This class defines a single encoding block for an encoder.

Type Default Details
in_channels int The number of input channels.
out_channels_first int The number of output channels after the first encoding step.
dimensions int The number of dimensions to consider. Possible options are 2 and 3.
normalization str The type of normalization to use. Possible options include "batch", "layer" and "instance".
pooling_type str The type of pooling to use.
pooling_kernel_size int The size of the pooling kernel.
preactivation bool False Whether to use preactivations.
is_first_block bool False Whether this is the first block of an encoder.
residual bool False Whether the encoder should be a residual network.
use_padding bool False Whether to use padding.
padding_mode str zeros The type of padding to use.
activation str ReLU The activation function that should be used.
dilation int None The amount of dilation that should be used.
dropout float 0.0 The dropout rate.

EncodingBlock.forward[source]

EncodingBlock.forward(x:Tensor)

The forward pass of the encoding block. Returns a list of torch.Tensors that define the outputs of the skip connections, and a torch.Tensor that is the output of the encoding block.

Type Default Details
x Tensor the input to the encoding block.

class Encoder[source]

Encoder(in_channels:int, out_channels_first:int, dimensions:int, pooling_type:str, num_encoding_blocks:int, normalization:str, pooling_kernel_size:int, preactivation:bool=False, residual:bool=False, use_padding:bool=False, padding_mode:str='zeros', activation:str='ReLU', initial_dilation:int=None, dropout:float=0.0) :: Module

This class defines an encoder that can be used for the construction of UNets [1]. An encoder is a neural network that takes the input, and outputs a feature vector for each input sample.

Type Default Details
in_channels int The number of input channels.
out_channels_first int The number of output channels after the first encoding step.
dimensions int The number of dimensions to consider. Possible options are 2 and 3.
pooling_type str The type of pooling to use.
num_encoding_blocks int The number of encoding blocks.
normalization str The type of normalization to use. Possible options include "batch", "layer" and "instance".
pooling_kernel_size int The size of the pooling kernel.
preactivation bool False Whether to use preactivations.
residual bool False Whether the encoder should be a residual network.
use_padding bool False Whether to use padding.
padding_mode str zeros The type of padding to use.
activation str ReLU The activation function that should be used.
initial_dilation int None The amount of dilation that should be used in the first encoding block.
dropout float 0.0 The dropout rate.

Encoder.forward[source]

Encoder.forward(x:Tensor)

The forward pass of the encoder. Returns a list of torch.Tensors that define the outputs of the skip connections, and a torch.Tensor that is the output of the encoder.

Type Default Details
x Tensor The input of the encoder.

References

[1] Falk, Thorsten, et al. "U-Net: deep learning for cell counting, detection, and morphometry." Nature methods 16.1 (2019): 67-70.