extorch.nn.modules.block

ResNetBasicBlock

ResNet basic block (Link).

ResNetBottleneckBlock

ResNet bottleneck block (Link).

class extorch.nn.modules.block.ResNetBasicBlock(in_channels: int, out_channels: int, stride: int, kernel_size: int = 3, affine: bool = True)[source]

Bases: torch.nn.modules.module.Module

ResNet basic block (Link).

Parameters
  • in_channels (int) – Number of channels in the input image.

  • out_channels (int) – Number of channels produced by the convolution.

  • stride (int) – Stride of the convolution.

  • kernel_size (int) – Size of the convolving kernel. Default: 3.

  • affine (bool) – A boolean value that when set to True, the batch-normalization layer has learnable affine parameters. Default: True.

Examples::
>>> m = ResNetBasicBlock(3, 10, 2, 3, True)
>>> input = torch.randn(3, 3, 32, 32)
>>> output = m(input)
expansion = 1
forward(input: torch.Tensor) torch.Tensor[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class extorch.nn.modules.block.ResNetBottleneckBlock(in_channels: int, out_channels: int, stride: int, affine: bool = True)[source]

Bases: torch.nn.modules.module.Module

ResNet bottleneck block (Link).

Parameters
  • in_channels (int) – Number of channels in the input image.

  • out_channels (int) – Number of channels produced by the convolution.

  • stride (int) – Stride of the convolution.

  • affine (bool) – A boolean value that when set to True, the batch-normalization layer has learnable affine parameters. Default: True.

Examples::
>>> m = ResNetBottleneckBlock(10, 10, 2, True)
>>> input = torch.randn(2, 10, 32, 32)
>>> output = m(input)
expansion = 4
forward(input: torch.Tensor) torch.Tensor[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool