CudaLSTM

class hy2dl.modelzoo.cudalstm.CudaLSTM(cfg: Config)

Bases: Module

LSTM model.

This class implements Pytorch’s cuda-optimized LSTM model (nn.LSTM).

The LSTM layer can operate either in a standard mode (hindcast only) or forecast mode. In forecast mode, the model implementes a sequential-forecast framework [1] rolling continuously through both the hindcast and forecast periods, using specific embedding layers for each case .

Parameters:

cfg (Config) – Configuration object containing model hyperparameters and settings.

References

forward(sample: dict[str, Any]) dict[str, Tensor]

Forward pass of the LSTM network.

Parameters:

sample (dict[str, Any]) – Dictionary with the different variables that will be used in the forward pass. See hy2dl.datasetzoo.basedataset.Basedataset.__getitems__() for details.

Returns:

Specific output of the model, depending on the head layer used. See hy2dl.modelzoo.head for details.

Return type:

dict[str, torch.Tensor]

Notes

Shape abbreviations used: - B: batch size - N: length of the target sequence, based on predict_last_n cofiguration argument - T: number of target variables