RNNCell

scalation.modeling.forecasting.neuralforecasting.RNNCell
trait RNNCell extends RecurrentBase

The RNNCell trait defines the structure and operations for a Recurrent Neural Network (RNN) cell. It includes weight matrices, bias vectors, and hidden states, along with methods for gradient clipping and parameter updates.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class RNN

Members list

Type members

Classlikes

protected case class HiddenState(n_mem: Int, n_seq: Int, seq_length: Int, var param: TensorD = ..., var grad: TensorD = ..., var pre_act_grad: MatrixD = ...)

Case class representing the hidden state of the RNN.

Case class representing the hidden state of the RNN.

Value parameters

grad

tensor for hidden state gradients

n_mem

number of memory units

n_seq

number of sequences

param

tensor for hidden state parameters

pre_act_grad

matrix for pre-activation gradients

seq_length

length of each sequence

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Inherited classlikes

protected case class ParamGroup[T](var param: T, var velocity: T, var grad: T)

Case class representing a group of parameters, including the parameter itself, its velocity, and its gradient.

Case class representing a group of parameters, including the parameter itself, its velocity, and its gradient.

Value parameters

grad

the gradient of the parameter, used for updating the parameter during training

param

the parameter (e.g., weights or biases)

velocity

the velocity associated with the parameter, used for momentum in optimization

Attributes

Inherited from:
RecurrentBase
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

override protected def clip_gradients(threshold: Double): Unit

Clip the gradients of the model parameters to a specified threshold. This method ensures that the gradients do not exceed the given threshold to prevent exploding gradients.

Clip the gradients of the model parameters to a specified threshold. This method ensures that the gradients do not exceed the given threshold to prevent exploding gradients.

Value parameters

threshold

the threshold value for gradient clipping

Attributes

Definition Classes
protected def get_previous_hidden_state(H: HiddenState, t: Int): MatrixD

Get the previous hidden state at time step t.

Get the previous hidden state at time step t.

Value parameters

H

The hidden state

t

The time step

Attributes

Returns

The previous hidden state matrix

protected def update_params(batch_size: Int, leaky: Boolean = ...): Unit

Update the model parameters based on the gradients. This method applies momentum and updates the parameters using the specified learning rate and batch size.

Update the model parameters based on the gradients. This method applies momentum and updates the parameters using the specified learning rate and batch size.

Value parameters

batch_size

the size of the batch used for training

leaky

a boolean flag indicating whether to use leaky updates (default is true)

Attributes

protected def zero_gradients(): Unit

Zero the gradients of the model parameters. This method sets all gradients of the weight matrices and bias vectors to zero.

Zero the gradients of the model parameters. This method sets all gradients of the weight matrices and bias vectors to zero.

Attributes

Inherited methods

protected def initializeBiasGroup(size: Int): ParamGroup[VectorD]

Initialize a bias group with a specified size.

Initialize a bias group with a specified size.

Value parameters

size

the size of the bias vector

Attributes

Returns

A ParamGroup containing the initialized bias vector, velocity vector, and gradient vector

Inherited from:
RecurrentBase
protected def initializeParamGroup(rows: Int, cols: Int, stdDev: Double): ParamGroup[MatrixD]

Initialize a parameter group with a specified number of rows, columns, and standard deviation.

Initialize a parameter group with a specified number of rows, columns, and standard deviation.

Value parameters

cols

the number of columns in the parameter matrix

rows

the number of rows in the parameter matrix

stdDev

the standard deviation for initializing the parameter matrix

Attributes

Returns

A ParamGroup containing the initialized parameter matrix, velocity matrix, and gradient matrix

Inherited from:
RecurrentBase
def log_(x: MatrixD): MatrixD

Attributes

Inherited from:
RecurrentBase
def log_(x: VectorD): VectorD

Attributes

Inherited from:
RecurrentBase

Attributes

Inherited from:
RecurrentBase

Attributes

Inherited from:
RecurrentBase

Attributes

Inherited from:
RecurrentBase
def tanh_(x: MatrixD): MatrixD

Attributes

Inherited from:
RecurrentBase
def tanh_(t: VectorD): VectorD

Attributes

Inherited from:
RecurrentBase
protected def updateBatch(matrix: MatrixD, batch_start: Int, batch_end: Int, newBatch: MatrixD): Unit

Updates a specific batch of rows in a matrix with new values.

Updates a specific batch of rows in a matrix with new values.

Value parameters

batch_end

the ending index (exclusive) of the batch in the matrix

batch_start

the starting index of the batch in the matrix

matrix

the matrix to be updated

newBatch

the new matrix containing the values to be inserted

Attributes

Throws
IllegalArgumentException

If the size of newBatch doesn't match the specified batch size

Inherited from:
RecurrentBase

Inherited and Abstract methods

def train(x: TensorD, y: TensorD): Unit

Abstract method for training the model with the given input and output tensors.

Abstract method for training the model with the given input and output tensors.

Value parameters

x

the input tensor

y

the output tensor

Attributes

Inherited from:
RecurrentBase

Concrete fields

lazy protected val H: HiddenState
lazy protected val U: ParamGroup[MatrixD]
lazy protected val V: ParamGroup[MatrixD]
lazy protected val W: ParamGroup[MatrixD]
lazy protected val b_h: ParamGroup[VectorD]
lazy protected val b_y: ParamGroup[VectorD]

Inherited fields

protected val CLASSIF: Boolean

Attributes

Inherited from:
RecurrentBase
protected val batch_size: Int

Attributes

Inherited from:
RecurrentBase
protected val eta: Double

Attributes

Inherited from:
RecurrentBase
protected val max_epochs: Int

Attributes

Inherited from:
RecurrentBase
protected val threshold: Double

Attributes

Inherited from:
RecurrentBase
protected val truncation_length: Int

Attributes

Inherited from:
RecurrentBase
protected val β: Double

Attributes

Inherited from:
RecurrentBase

Inherited and Abstract fields

protected val L: VectorD

Attributes

Inherited from:
RecurrentBase
protected val loss_per_epoch: VectorD

Attributes

Inherited from:
RecurrentBase
protected val n_mem: Int

Attributes

Inherited from:
RecurrentBase
protected val n_seq: Int

Attributes

Inherited from:
RecurrentBase
protected val n_var: Int

Attributes

Inherited from:
RecurrentBase
protected val seq_length: Int

Attributes

Inherited from:
RecurrentBase
protected val x: TensorD

Attributes

Inherited from:
RecurrentBase
protected val y: TensorD

Attributes

Inherited from:
RecurrentBase