src.model.residual module

src.model.residual module#

class src.model.residual.Residual(*args: Any, **kwargs: Any)[source]#

Bases: Module

Residual block with an optional projection shortcut.

Implements y = f(x) + x. When the input and output dimensions differ, a linear projection is applied to map x to the output dimension.

__init__(*layers, input_dim=None, output_dim=None)[source]#
Parameters:
  • *layers (nn.Module) – Sequence of layers on the main path.

  • input_dim (int, optional) – Input dimension. Needed only when the input and output dimensions differ.

  • output_dim (int, optional) – Output dimension.

forward(x)[source]#