LayerNorm

scalation.modeling.autograd.LayerNorm
class LayerNorm(dModel: Int, eps: Double = ...)(using ops: AutogradOps) extends Module

The LayerNorm class implements Layer Normalization as described in: "Layer Normalization" by Jimmy Lei Ba, Jamie Ryan Kiros, Geoffrey E. Hinton

Value parameters

dModel

the number of features in the input

eps

a small value to avoid division by zero

ops

the autograd operations

Attributes

See also
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 beta: Variabl
val gamma: 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