Skip to main content
Elman proposed this classic recurrent neural network (RNN) in 1990, where each layer uses the following recurrent transformation: htl=Activation([yt,xt(h),x(s)]Wih+bih+ht1lWhh+bhh)\mathbf{h}^{l}_{t} = \mathrm{Activation}([\mathbf{y}_{t},\mathbf{x}^{(h)}_{t},\mathbf{x}^{(s)}] W^{\intercal}_{ih} + b_{ih} + \mathbf{h}^{l}_{t-1} W^{\intercal}_{hh} + b_{hh}) where htl\mathbf{h}^{l}_{t}, is the hidden state of RNN layer ll for time tt, yt\mathbf{y}_{t} is the input at time tt and ht1\mathbf{h}_{t-1} is the hidden state of the previous layer at t1t-1, x(s)\mathbf{x}^{(s)} are static exogenous inputs, xt(h)\mathbf{x}^{(h)}_{t} historic exogenous, x[:t+H](f)\mathbf{x}^{(f)}_{[:t+H]} are future exogenous available at the time of the prediction. The available activations are tanh, and relu. The predictions are obtained by transforming the hidden states into contexts c[t+1:t+H]\mathbf{c}_{[t+1:t+H]}, that are decoded and adapted into y^[t+1:t+H],[q]\mathbf{\hat{y}}_{[t+1:t+H],[q]} through MLPs. References Figure 1. Single Layer Elman RNN with MLP decoder. Figure 1. Single Layer Elman RNN with MLP decoder.

RNN

RNN

Bases: BaseModel RNN Multi Layer Elman RNN (RNN), with MLP decoder. The network has tanh or relu non-linearities, it is trained using ADAM stochastic gradient descent. The network accepts static, historic and future exogenous data. Parameters:

RNN.fit

Fit. The fit method, optimizes the neural network’s weights using the initialization parameters (learning_rate, windows_batch_size, …) and the loss function as defined during the initialization. Within fit we use a PyTorch Lightning Trainer that inherits the initialization’s self.trainer_kwargs, to customize its inputs, see PL’s trainer arguments. The method is designed to be compatible with SKLearn-like classes and in particular to be compatible with the StatsForecast library. By default the model is not saving training checkpoints to protect disk memory, to get them change enable_checkpointing=True in __init__. Parameters: Returns:

RNN.predict

Predict. Neural network prediction with PL’s Trainer execution of predict_step. Parameters: Returns:

Usage Example