Skip to main content

Linear

y = x @ weight.T + bias over a [out_features, in_features] weight (and a [out_features] bias when bias=True).

__init__

__init__(self, in_features: 'int', out_features: 'int', bias: 'bool' = True, *, dtype: 'DataType | None' = None, device: 'Device | None' = None, activation: 'Activation | None' = None) -> 'None'

Declare the layer's slots. dtype=None adopts the bound payload's dtype; device=None declares on cpu; activation fuses an epilogue into every forward.

extra_repr

extra_repr(self) -> 'str'

One line of per-class detail for :meth:__repr__ (a layer prints its geometry here).

forward

forward(self, x: 'Tensor') -> 'Tensor'

Subclasses define the computation here; call the module itself (m(x)), not forward directly.

from_weights

from_weightsConstruct FROM tensors: geometry, dtype, and device read off

Construct FROM tensors: geometry, dtype, and device read off weight [out, in]; an optional bias [out] binds beside it.

set_weights

set_weights(self, weight: 'Tensor', bias: 'Tensor | None' = None) -> 'None'

Bind the declared slots directly; raises on a shape mismatch.