RecurrentNetwork

class RecurrentNetwork(rnn_type='simple', n_layers=1, n_units=64, dropout_intermediate=0.0, dropout_output=0.0, bidirectional=False, activation='tanh', return_sequence_last=False)[source]

Bases: BaseDeepLearningNetwork

Implements a Recurrent Neural Network (RNN) for time series forecasting.

This implementation provides a flexible RNN architecture that can be configured to use different types of recurrent cells including Simple RNN, Long Short-Term Memory (LSTM) [1], and Gated Recurrent Unit (GRU) [2]. The network supports multiple layers, bidirectional processing, and various dropout configurations for regularization.

Parameters:
rnn_typestr, default=’lstm’

Type of RNN cell to use (‘lstm’, ‘gru’, or ‘simple’).

n_layersint, default=1

Number of recurrent layers.

n_unitslist or int, default=64

Number of units in each recurrent layer. If an int, the same number of units is used in each layer. If a list, specifies the number of units for each layer and must match the number of layers.

dropout_intermediatefloat, default=0.0

Dropout rate applied after each intermediate recurrent layer (not last layer).

dropout_outputfloat, default=0.0

Dropout rate applied after the last recurrent layer.

bidirectionalbool, default=False

Whether to use bidirectional recurrent layers.

activationstr or list of str, default=’tanh’

Activation function(s) for the recurrent layers. If a string, the same activation is used for all layers. If a list, specifies activation for each layer and must match the number of layers.

return_sequence_lastbool, default=False

Whether the last recurrent layer returns the full sequence (True) or just the last output (False).

References

[1]

Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780.

[2]

Cho, K., Van Merriënboer, B., Gulcehre, C., Bahdanau, D., Bougares, F., Schwenk, H., & Bengio, Y. (2014). Learning phrase representations using RNN encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078.

Methods

build_network(input_shape, **kwargs)

Construct a network and return its input and output layers.

build_network(input_shape, **kwargs)[source]

Construct a network and return its input and output layers.

Parameters:
input_shapetuple

The shape of the data fed into the input layer (n_timepoints, n_features)

kwargsdict

Additional keyword arguments to be passed to the network

Returns:
input_layera keras layer
output_layera keras layer