Helper Module for Deep Learning.
The U-Net is a convolutional encoder-decoder neural network.
-
class
pynet.models.unet.DoubleConv(in_channels, out_channels, dim, kernel_size=3, stride=1, padding=1, bias=True, batchnorm=True)[source]¶
-
class
pynet.models.unet.Down(in_channels, out_channels, dim, pooling=True, batchnorm=True)[source]¶ A helper Module that performs 2 convolutions and 1 MaxPool. A LeakyReLU activation and optionally a BatchNorm follows each convolution.
-
class
pynet.models.unet.UNet(num_classes, in_channels=1, depth=5, start_filts=64, up_mode='transpose', merge_mode='concat', batchnorm=False, dim='3d', input_shape=None)[source]¶ UNet.
The U-Net is a convolutional encoder-decoder neural network. Contextual spatial information (from the decoding, expansive pathway) about an input tensor is merged with information representing the localization of details (from the encoding, compressive pathway). Modifications to the original paper:
padding is used in 3x3x3 convolutions to prevent loss of border pixels
merging outputs does not require cropping due to (1)
residual connections can be used by specifying UNet(merge_mode=’add’)
if non-parametric upsampling is used in the decoder pathway (specified by upmode=’upsample’), then an additional 1x1x1 3d convolution occurs after upsampling to reduce channel dimensionality by a factor of 2. This channel halving happens with the convolution in the tranpose convolution (specified by upmode=’transpose’)
-
__init__(num_classes, in_channels=1, depth=5, start_filts=64, up_mode='transpose', merge_mode='concat', batchnorm=False, dim='3d', input_shape=None)[source]¶ Init class.
- Parameters
num_classes: int
the number of features in the output segmentation map.
in_channels: int, default 1
number of channels in the input tensor.
depth: int, default 5
number of layers in the U-Net.
start_filts: int, default 64
number of convolutional filters for the first conv.
up_mode: string, default ‘transpose’
type of upconvolution. Choices: ‘transpose’ for transpose convolution, ‘upsample’ for nearest neighbour upsampling.
merge_mode: str, default ‘concat’
the skip connections merging strategy.
batchnorm: bool, default False
normalize the inputs of the activation function.
dim: str, default ‘3d’
‘3d’ or ‘2d’ input data.
input_shape: uplet
the tensor data shape (X, Y, Z) used during upsample (by default use a scale factor of 2).
-
class
pynet.models.unet.Up(in_channels, out_channels, dim, merge_mode='concat', up_mode='transpose', batchnorm=True, shape=None)[source]¶ A helper Module that performs 2 convolutions and 1 UpConvolution. A LeakyReLU activation and optionally a BatchNorm follows each convolution.
Follow us
Inspired by AZMIND template.