Linear

scalation.modeling.autograd.Linear
See theLinear companion object
class Linear(inFeatures: Int, outFeatures: Int)(using ops: AutogradOps) extends Module

A fully connected linear (affine) layer: output =weight.bmm(input) + bias Computes a linear transformation of the input tensor:

  • Weight shape: (1, outFeatures, inFeatures)
  • Bias shape: (1, outFeatures, 1)
  • Input shape: (batch, inFeatures, 1)
  • Output shape: (batch, outFeatures, 1) The weight and bias are learnable parameters wrapped in Variabl. Internally uses batched matrix multiplication and broadcasting for bias addition.

Value parameters

inFeatures

the number of input features

outFeatures

the number of output features

Attributes

Companion
object
Graph
Supertypes
class Module
class BaseModule
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def forward(input: Variabl): Variabl

Forward pass for a single input Variable. Must be implemented by subclasses.

Forward pass for a single input Variable. Must be implemented by subclasses.

Attributes

Definition Classes
override def parameters: IndexedSeq[Variabl]

Return all trainable parameters, including those from submodules.

Return all trainable parameters, including those from submodules.

Attributes

Definition Classes

Inherited methods

def apply(input: Variabl): Variabl

Alias for forward, allows calling the module as a function: module(x).

Alias for forward, allows calling the module as a function: module(x).

Attributes

Inherited from:
Module
def eval(): Unit

Set the module to evaluation mode (and all submodules recursively).

Set the module to evaluation mode (and all submodules recursively).

Attributes

Inherited from:
BaseModule
def gradients: IndexedSeq[TensorD]

Return the gradients of all parameters.

Return the gradients of all parameters.

Attributes

Inherited from:
BaseModule
def setParameters(newParams: IndexedSeq[Variabl]): Unit

Replace the current parameters with new ones. Useful for weight updates, loading saved models, etc.

Replace the current parameters with new ones. Useful for weight updates, loading saved models, etc.

Value parameters

newParams

The new parameter list to assign

Attributes

Inherited from:
BaseModule
def train(mode: Boolean = ...): Unit

Set the module to training mode (and all submodules recursively).

Set the module to training mode (and all submodules recursively).

Attributes

Inherited from:
BaseModule
def zeroGrad()(using ops: AutogradOps): Unit

Zero out all gradients (in-place).

Zero out all gradients (in-place).

Attributes

Inherited from:
BaseModule

Concrete fields

val bias: Variabl

Inherited fields

var inTrainingMode: Boolean

Flag to control training or evaluation behavior.

Flag to control training or evaluation behavior.

Attributes

Inherited from:
BaseModule
lazy val subModules: IndexedSeq[BaseModule]

Automatically detect submodules (other BaseModules) within this module.

Automatically detect submodules (other BaseModules) within this module.

Attributes

Inherited from:
BaseModule