bitorch.models.resnet_e.BasicBlock

class bitorch.models.resnet_e.BasicBlock(in_channels: int, out_channels: int, stride: int)[source]

BasicBlock from “Back to Simplicity: How to Train Accurate BNNs from Scratch?” paper. This is used for ResNetE layers.

Methods

__init__

builds body and downsampling layers

forward

forwards the input tensor x through the building block.

Attributes

__init__(in_channels: int, out_channels: int, stride: int) None[source]

builds body and downsampling layers

Parameters:
  • in_channels (int) – input channels for building block

  • out_channels (int) – output channels for building block

  • stride (int) – stride to use in convolutions

forward(x: Tensor) Tensor[source]

forwards the input tensor x through the building block.

Parameters:

x (torch.Tensor) – the input tensor

Returns:

the output of this building block after adding the input tensor as residual value.

Return type:

torch.Tensor