eazygrad.nn.Linear

class eazygrad.nn.Linear(n_in: int, n_out: int, bias: bool = True, requires_grad: bool = True)[source]

Bases: Module

Fully connected linear layer.

Parameters:
  • n_in (int) – Number of input features.

  • n_out (int) – Number of output features.

  • bias (bool, default=True) – Whether to include a learnable bias term.

  • requires_grad (bool, default=True) – Whether the layer parameters should participate in automatic differentiation.

Notes

The layer stores weights with shape (n_in, n_out) and applies the transformation x @ weights + bias to batched 2D inputs.

forward(x: _Tensor) _Tensor[source]

Apply the forward pass of the module to the input x