Skip to main content

Linear

Linear(in_features, out_features, bias=True, device=None, dtype=None, *, activation=None)

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

Args: in_features: the size of each input sample. out_features: the size of each output sample. bias: declare the bias slot. device: where the layer's tensors live (a device or its string form); None declares on the cpu. dtype: the weight dtype the layer declares; None declares the default dtype (:func:~clika_runtime.get_default_dtype). A load_state_dict casts the checkpoint to the declared dtype; assign=True adopts the checkpoint's own dtype instead. activation: a fused epilogue applied to every output ("gelu", "silu", ... or an :class:~clika_runtime.Activation value); None for none.

__init__​

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

Initialize self. See help(type(self)) for accurate signature.

extra_repr​

extra_repr(self) -> 'str'

extra_repr() -> str

One line of per-class detail for :meth:__repr__; a layer prints its geometry here (in_features=64, out_features=256).

forward​

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

forward(input) -> Tensor

[*, in_features] to [*, out_features].

from_weights​

from_weightsfrom_weights(weight, bias=None) -> Linear

from_weights(weight, bias=None) -> Linear

Construct FROM tensors: geometry, dtype, and device read off weight ([out_features, in_features]); an optional bias ([out_features]) binds beside it.

set_weights​

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

set_weights(weight, bias=None) -> None

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