Module

scalation.modeling.autograd.Module
abstract class Module(localParameters: IndexedSeq[Variabl] = ...) extends BaseModule

Standard module for layers that take a single input (e.g., Linear, Conv1D). Defines the abstract forward function for single input.

Value parameters

localParameters

the parameters (Variables) directly belonging to this module

Attributes

Graph
Supertypes
class BaseModule
class Object
trait Matchable
class Any
Known subtypes
class LayerNorm
class Linear

Members list

Value members

Abstract methods

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

Concrete 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 methods

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 parameters: IndexedSeq[Variabl]

Return all trainable parameters, including those from submodules.

Return all trainable parameters, including those from submodules.

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

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