BaseModule

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

The BaseModule is a base class for all neural network modules (layers, blocks, models). Provides support for:

  • Parameter registration
  • Automatic submodule detection
  • Gradient management (zeroing)
  • Training/evaluation mode switching Modules are structured hierarchically: a module can contain submodules.

Value parameters

localParameters

the parameters (Variables) directly belonging to this module

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class GRU
class Module
class LayerNorm
class Linear
class RNN
class SeqModule
Show all

Members list

Value members

Concrete 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

def gradients: IndexedSeq[TensorD]

Return the gradients of all parameters.

Return the gradients of all parameters.

Attributes

def parameters: IndexedSeq[Variabl]

Return all trainable parameters, including those from submodules.

Return all trainable parameters, including those from submodules.

Attributes

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

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

def zeroGrad()(using ops: AutogradOps): Unit

Zero out all gradients (in-place).

Zero out all gradients (in-place).

Attributes

Concrete fields

var inTrainingMode: Boolean

Flag to control training or evaluation behavior.

Flag to control training or evaluation behavior.

Attributes

lazy val subModules: IndexedSeq[BaseModule]

Automatically detect submodules (other BaseModules) within this module.

Automatically detect submodules (other BaseModules) within this module.

Attributes