Linear class

Inheritance

Constructors

Linear(int inFeatures, int outFeatures, {bool bias = true, Device device = Device.CPU, int seed = 0})
Weight init: Kaiming-uniform with a = sqrt(5) (matches PyTorch's default). Bias, when present, uses uniform in [-1/sqrt(fan_in), +1/sqrt(fan_in)].

Properties

bias Tensor?
final
hashCode int
The hash code for this object.
no setterinherited
inFeatures int
final
outFeatures int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
training bool
Whether this module is in training mode. Layers that behave differently between training and inference (e.g. Dropout) read this flag in their call method. Defaults to training mode.
getter/setter pairinherited
weight Tensor
final

Methods

call(Tensor x) Tensor
Forward: x @ W.T + b. x shape [..., inFeatures], returns [..., outFeatures]. Rank-3 or higher input is handled by reshaping the leading dims into a single row axis and back.
eval() → void
Put this module (and any registered submodules) into evaluation mode.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parameters() List<Tensor>
Trainable tensors owned by this module (and its submodules).
override
submodules() List<Module>
Submodules owned by this module. Subclasses that compose other modules should override this so train() / eval() propagate. Default: empty.
inherited
toString() String
A string representation of this object.
inherited
train() → void
Put this module (and any registered submodules) into training mode.
inherited
zeroGrad() → void
Zero every parameter's gradient. Safe to call before each backward.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited