Residual Block#

class ResidualBlock(input_dim, output_dim, hidden_dim, spectral_norm=False, activation=ReLU())[source]#

Bases: Module

Residual block class.

See also

Original reference: He, Kaiming, et al. Deep residual learning for image recognition. Proceedings of the IEEE conference on computer vision and pattern recognition. 2016. DOI: https://arxiv.org/pdf/1512.03385.pdf.

Initialization of the ResidualBlock class.

Parameters:
  • input_dim (int) – The input dimension.

  • output_dim (int) – The output dimension.

  • hidden_dim (int) – The hidden dimension.

  • spectral_norm (bool) – If True, the spectral normalization is applied to the feedforward layers. Default is False.

  • activation (torch.nn.Module) – The activation function. Default is torch.nn.ReLU.

forward(x)[source]#

Forward pass.

Parameters:

x (torch.Tensor) – The input tensor.

Returns:

The output tensor.

Return type:

torch.Tensor