WeightBiasMixin

class WeightBiasMixin(weight: Tensor, bias: Tensor | None, requires_grad: bool = False)[source]

Bases: WeightMixin

Mixin for connections with weights and biases.

Parameters:
  • weight (torch.Tensor) – initial connection weights.

  • bias (torch.Tensor) – initial connection biases, if any.

  • requires_grad (bool, optional) – if the parameters created require gradients. Defaults to False.

Caution

This must be added to a class which inherits from Module, and the constructor for this mixin must be called after the module constructor.

Note

This registers a parameter weight_, and if bias is not None, a parameter bias_ as well.

property bias: Parameter | None

Learnable connection biases.

Parameters:

value (torch.Tensor | nn.Parameter) – new biases.

Returns:

present biases, if any.

Return type:

nn.Parameter | None