RESNETBLOCK#

Classes#

class backbone.ResNetBlock.BasicBlock(in_planes, planes, stride=1)[source]#

Bases: Module

The basic block of ResNet.

expansion = 1#
forward(x)[source]#

Compute a forward pass.

Parameters:

x (Tensor) – input tensor (batch_size, input_size)

Returns:

output tensor (10)

Return type:

Tensor

class backbone.ResNetBlock.ResNet(block, num_blocks, num_classes, nf)[source]#

Bases: MammothBackbone

ResNet network architecture. Designed for complex datasets.

forward(x, returnt='out')[source]#

Compute a forward pass.

Parameters:
  • x (Tensor) – input tensor (batch_size, *input_shape)

  • returnt – return type (a string among ‘out’, ‘features’, ‘both’, and ‘full’)

Returns:

output tensor (output_classes)

Return type:

Tensor

set_return_prerelu(enable=True)[source]#

Functions#

backbone.ResNetBlock.conv3x3(in_planes, out_planes, stride=1)[source]#

Instantiates a 3x3 convolutional layer with no bias.

Parameters:
  • in_planes (int) – number of input channels

  • out_planes (int) – number of output channels

  • stride (int) – stride of the convolution

Returns:

convolutional layer

Return type:

conv2d

backbone.ResNetBlock.resnet18(num_classes, num_filters=64)[source]#

Instantiates a ResNet18 network.

Parameters:
  • num_classes (int) – number of output classes

  • num_filters (int) – number of filters

Returns:

ResNet network

Return type:

ResNet

backbone.ResNetBlock.resnet34(num_classes, num_filters=64)[source]#

Instantiates a ResNet34 network.

Parameters:
  • num_classes (int) – number of output classes

  • num_filters (int) – number of filters

Returns:

ResNet network

Return type:

ResNet