cellmap_segmentation_challenge.models.resnet#

Classes

ResNet(ndims, **kwargs)

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int) -- the number of channels in output images (default is ngf :param ngf: :type ngf: int :param norm_layer -- normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation -- non-linearity layer to apply: :type activation -- non-linearity layer to apply: default is ReLU :param n_downsampling -- number of times to downsample data before ResBlocks:

Resnet2D([input_nc, output_nc, ngf, ...])

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int) -- the number of channels in output images (default is ngf :param ngf: :type ngf: int :param norm_layer -- normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation -- non-linearity layer to apply: :type activation -- non-linearity layer to apply: default is ReLU :param n_downsampling -- number of times to downsample data before ResBlocks:

Resnet3D([input_nc, output_nc, ngf, ...])

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int :param ngf: :type ngf: int :param norm_layer -- normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation -- non-linearity layer to apply: :type activation -- non-linearity layer to apply: default is ReLU :param n_downsampling -- number of times to downsample data before ResBlocks:

ResnetBlock2D(dim, padding_type, norm_layer, ...)

Initialize the Resnet block A resnet block is a conv block with skip connections We construct a conv block with build_conv_block function, and implement skip connections in <forward> function.

ResnetBlock3D(dim, padding_type, norm_layer, ...)

Initialize the Resnet block A resnet block is a conv block with skip connections We construct a conv block with build_conv_block function, and implement skip connections in <forward> function.

class cellmap_segmentation_challenge.models.resnet.Resnet2D(input_nc=1, output_nc=None, ngf=64, norm_layer=<class 'torch.nn.modules.instancenorm.InstanceNorm2d'>, use_dropout=False, n_blocks=6, padding_type='reflect', activation=<class 'torch.nn.modules.activation.ReLU'>, n_downsampling=2)[source]#

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int) – the number of channels in output images (default is ngf :param ngf: :type ngf: int :param norm_layer – normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation – non-linearity layer to apply: :type activation – non-linearity layer to apply: default is ReLU :param n_downsampling – number of times to downsample data before ResBlocks:

forward(input)[source]#

Standard forward

class cellmap_segmentation_challenge.models.resnet.ResnetBlock2D(dim, padding_type, norm_layer, use_dropout, use_bias, activation=<class 'torch.nn.modules.activation.ReLU'>)[source]#

Initialize the Resnet block A resnet block is a conv block with skip connections We construct a conv block with build_conv_block function, and implement skip connections in <forward> function. Original Resnet paper: https://arxiv.org/pdf/1512.03385.pdf

build_conv_block(dim, padding_type, norm_layer, use_dropout, use_bias, activation=<class 'torch.nn.modules.activation.ReLU'>)[source]#

Construct a convolutional block. :param dim: :type dim: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param norm_layer – normalization layer: :param use_dropout: :type use_dropout: bool :param use_bias: :type use_bias: bool :param activation – non-linearity layer to apply: :type activation – non-linearity layer to apply: default is ReLU

Returns a conv block (with a conv layer, a normalization layer, and a non-linearity layer)

crop(x, shape)[source]#

Center-crop x to match spatial dimensions given by shape.

forward(x)[source]#

Forward function (with skip connections)

class cellmap_segmentation_challenge.models.resnet.Resnet3D(input_nc=1, output_nc=None, ngf=64, norm_layer=<class 'torch.nn.modules.instancenorm.InstanceNorm3d'>, use_dropout=False, n_blocks=6, padding_type='reflect', activation=<class 'torch.nn.modules.activation.ReLU'>, n_downsampling=2)[source]#

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int :param ngf: :type ngf: int :param norm_layer – normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation – non-linearity layer to apply: :type activation – non-linearity layer to apply: default is ReLU :param n_downsampling – number of times to downsample data before ResBlocks:

forward(input)[source]#

Standard forward

class cellmap_segmentation_challenge.models.resnet.ResnetBlock3D(dim, padding_type, norm_layer, use_dropout, use_bias, activation=<class 'torch.nn.modules.activation.ReLU'>)[source]#

Initialize the Resnet block A resnet block is a conv block with skip connections We construct a conv block with build_conv_block function, and implement skip connections in <forward> function. Original Resnet paper: https://arxiv.org/pdf/1512.03385.pdf

build_conv_block(dim, padding_type, norm_layer, use_dropout, use_bias, activation=<class 'torch.nn.modules.activation.ReLU'>)[source]#

Construct a convolutional block. :param dim: :type dim: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param norm_layer – normalization layer: :param use_dropout: :type use_dropout: bool :param use_bias: :type use_bias: bool :param activation – non-linearity layer to apply: :type activation – non-linearity layer to apply: default is ReLU

Returns a conv block (with a conv layer, a normalization layer, and a non-linearity layer)

crop(x, shape)[source]#

Center-crop x to match spatial dimensions given by shape.

forward(x)[source]#

Forward function (with skip connections)

class cellmap_segmentation_challenge.models.resnet.ResNet(ndims, **kwargs)[source]#

Construct a Resnet :param input_nc: :type input_nc: int :param output_nc: :type output_nc: int) – the number of channels in output images (default is ngf :param ngf: :type ngf: int :param norm_layer – normalization layer: :param use_dropout: :type use_dropout: bool :param n_blocks: :type n_blocks: int :param padding_type: reflect | replicate | zeros | valid :type padding_type: str :param activation – non-linearity layer to apply: :type activation – non-linearity layer to apply: default is ReLU :param n_downsampling – number of times to downsample data before ResBlocks: