The RNN class implements Recurrent Neural Network (RNN) via Back Propagation Through Time (BPTT). At each time point x_t, there is a vector representing several variables or the encoding of a word. Intended to work for guessing the next work in a sentence or for multi-horizon forecasting.
Value parameters
- fname
-
the feature/variable names
- n_mem
-
the size for hidden state (h) (dimensionality of memory)
- x
-
the input sequence/time series
- y
-
the output sequence/time series
- y_orig
-
the original target matrix before any preprocessing
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Type members
Inherited classlikes
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
- Inherited from:
- RNNCell
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
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 Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Performs the backward pass of the RNN, computing gradients for the network parameters. This function implements backpropagation through time (BPTT) for a batch of sequences. It calculates the gradients of the loss with respect to the network parameters, which are then used to update the weights in the training process.
Performs the backward pass of the RNN, computing gradients for the network parameters. This function implements backpropagation through time (BPTT) for a batch of sequences. It calculates the gradients of the loss with respect to the network parameters, which are then used to update the weights in the training process.
Value parameters
- H
-
the hidden state tensor, default is the class member H
- batch_end
-
the ending index (inclusive) of the current batch in the full dataset
- batch_start
-
the starting index of the current batch in the full dataset
- x
-
the input tensor of shape [seq_length, n_var, batch_size]
- y
-
the target tensor of shape [seq_length, output_dim, batch_size]
Attributes
- Returns
-
Unit (no return value, updates are made to class members)
Performs the forward pass of the RNN, computing the predictions and loss for the network. This function implements the forward propagation for a batch of sequences. It calculates the predictions for each time step and computes the loss based on the difference between the predictions and the target values.
Performs the forward pass of the RNN, computing the predictions and loss for the network. This function implements the forward propagation for a batch of sequences. It calculates the predictions for each time step and computes the loss based on the difference between the predictions and the target values.
Value parameters
- H
-
the hidden state tensor, default is the class member H
- L
-
the loss vector to store the loss values for each time step
- batch_end
-
the ending index (inclusive) of the current batch in the full dataset
- batch_start
-
the starting index of the current batch in the full dataset
- x
-
the input tensor of shape [seq_length, n_var, batch_size]
- y
-
the target tensor of shape [seq_length, output_dim, batch_size]
Attributes
- Returns
-
Unit (no return value, updates are made to class members)
Tests the RNN model by reconstructing predictions and comparing them with the original data. This function reconstructs the full-length predictions from overlapping sequences, prints the dimensions of the reconstructed predictions and original data, and plots the predictions against the original data. It also calculates and prints the SMAPE and MAE values for each variable, and plots the loss function over epochs.
Tests the RNN model by reconstructing predictions and comparing them with the original data. This function reconstructs the full-length predictions from overlapping sequences, prints the dimensions of the reconstructed predictions and original data, and plots the predictions against the original data. It also calculates and prints the SMAPE and MAE values for each variable, and plots the loss function over epochs.
Value parameters
- original_extremes
-
a tuple representing the original extremes of the data for unscaling. default is (1.0, 1.0).
Attributes
Trains the RNN model using the provided input and target tensors. This function implements the training loop for the RNN model. It iterates over the specified number of epochs, divides the data into batches, performs forward and backward propagation, clips gradients to avoid exploding gradients, and updates the model parameters.
Trains the RNN model using the provided input and target tensors. This function implements the training loop for the RNN model. It iterates over the specified number of epochs, divides the data into batches, performs forward and backward propagation, clips gradients to avoid exploding gradients, and updates the model parameters.
Value parameters
- x
-
the input tensor of shape [seq_length, n_var, n_seq]
- y
-
the target tensor of shape [seq_length, output_dim, n_seq]
Attributes
- Returns
-
Unit (no return value, updates are made to class members)
- Definition Classes
Inherited methods
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
- Inherited from:
- RNNCell
Diagnose and return the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.
Diagnose and return the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.
Value parameters
- w
-
the weights on the instances (defaults to null)
- y
-
the actual response/output vector to use (test/full)
- yp
-
the predicted response/output vector (test/full)
Attributes
- See also
-
Regression_WLSOverride to add more metrics. - Inherited from:
- FitM
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Attributes
- Inherited from:
- FitM
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
- Inherited from:
- RNNCell
Return the help string that describes the Quality of Fit (QoF) metrics/measures.
Return the help string that describes the Quality of Fit (QoF) metrics/measures.
Attributes
- See also
-
Fitfor an implementation. Override to correspond to fitLabel. - Inherited from:
- FitM
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
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
Attributes
- Inherited from:
- RecurrentBase
Attributes
- Inherited from:
- RecurrentBase
Return the coefficient of determination (R^2). Must call diagnose first.
Return the coefficient of determination (R^2). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Attributes
- Inherited from:
- RecurrentBase
Attributes
- Inherited from:
- RecurrentBase
Return the sum of the squares for error (sse). Must call diagnose first.
Return the sum of the squares for error (sse). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Produce a QoF summary for a model with diagnostics for each predictor 'x_j' and the overall Quality of Fit (QoF).
Produce a QoF summary for a model with diagnostics for each predictor 'x_j' and the overall Quality of Fit (QoF).
Value parameters
- b
-
the parameters/coefficients for the model
- fname
-
the array of feature/variable names
- vifs
-
the Variance Inflation Factors (VIFs)
- x_
-
the testing/full data/input matrix
Attributes
- Inherited from:
- FitM
Attributes
- Inherited from:
- RecurrentBase
Attributes
- Inherited from:
- RecurrentBase
Attributes
- Inherited from:
- RecurrentBase
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
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
- Inherited from:
- RNNCell
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 from:
- RNNCell