RNNNet¶
- class RNNNet(input_size: int, num_layers: int, hidden_size: int, lr: float, loss: torch.nn.modules.module.Module, optimizer_params: Optional[dict])[source]¶
Bases:
etna.models.base.DeepBaseNet
RNN based Lightning module with LSTM cell.
Init RNN based on LSTM cell.
- Parameters
input_size (int) – size of the input feature space: target plus extra features
num_layers (int) – number of layers
hidden_size (int) – size of the hidden state
lr (float) – learning rate
loss (torch.nn.Module) – loss function
optimizer_params (Optional[dict]) – parameters for optimizer for Adam optimizer (api reference
torch.optim.Adam
)
- Return type
None
Methods
Optimizer configuration.
forward
(x, *args, **kwargs)Forward pass.
make_samples
(df, encoder_length, decoder_length)Make samples from segment DataFrame.
step
(batch, *args, **kwargs)Step for loss computation for training or validation.
Attributes
- configure_optimizers() torch.optim.optimizer.Optimizer [source]¶
Optimizer configuration.
- Return type
- forward(x: etna.models.nn.rnn.RNNBatch, *args, **kwargs)[source]¶
Forward pass.
- Parameters
x (etna.models.nn.rnn.RNNBatch) – batch of data
- Returns
forecast with shape (batch_size, decoder_length, 1)
- make_samples(df: pandas.core.frame.DataFrame, encoder_length: int, decoder_length: int) Iterator[dict] [source]¶
Make samples from segment DataFrame.
- Parameters
df (pandas.core.frame.DataFrame) –
encoder_length (int) –
decoder_length (int) –
- Return type
Iterator[dict]
- step(batch: etna.models.nn.rnn.RNNBatch, *args, **kwargs)[source]¶
Step for loss computation for training or validation.
- Parameters
batch (etna.models.nn.rnn.RNNBatch) – batch of data
- Returns
loss, true_target, prediction_target