analogvnn.nn.Linear#

Module Contents#

Classes#

LinearBackpropagation

The backpropagation module of a linear layer.

Linear

A linear layer.

class analogvnn.nn.Linear.LinearBackpropagation(layer: torch.nn.Module = None)[source]#

Bases: analogvnn.backward.BackwardModule.BackwardModule

The backpropagation module of a linear layer.

forward(x: torch.Tensor)[source]#

Forward pass of the linear layer.

Parameters:

x (Tensor) – The input of the linear layer.

Returns:

The output of the linear layer.

Return type:

Tensor

backward(grad_output: Optional[torch.Tensor]) Optional[torch.Tensor][source]#

Backward pass of the linear layer.

Parameters:

grad_output (Optional[Tensor]) – The gradient of the output.

Returns:

The gradient of the input.

Return type:

Optional[Tensor]

class analogvnn.nn.Linear.Linear(in_features: int, out_features: int, bias: bool = True)[source]#

Bases: analogvnn.nn.module.Layer.Layer

A linear layer.

Variables:
  • in_features (int) – The number of input features.

  • out_features (int) – The number of output features.

  • weight (nn.Parameter) – The weight of the layer.

  • bias (nn.Parameter) – The bias of the layer.

__constants__ = ['in_features', 'out_features'][source]#
in_features: int[source]#
out_features: int[source]#
weight: torch.nn.Parameter[source]#
bias: Optional[torch.nn.Parameter][source]#
reset_parameters()[source]#

Reset the parameters of the layer.

extra_repr() str[source]#

Extra representation of the linear layer.

Returns:

The extra representation of the linear layer.

Return type:

str