SequentialForecastLSTM

class neuralhydrology.modelzoo.sequential_forecast_lstm.SequentialForecastLSTM(cfg: Config)

Bases: BaseModel

A forecasting model that uses a single LSTM sequence with multiple embedding layers.

This is a forecasting model that uses a single sequential (LSTM) model that rolls out through both the hindcast and forecast sequences. The difference between this and a standard CudaLSTM is (1) this model uses both hindcast and forecast input features, and (2) it uses a separate embedding network for the hindcast period and the forecast period.

Do not use this model with forecast_overlap > 0.

Parameters:

cfg (Config) – The run configuration.

Raises:
  • ValueError if forecast_overlap > 0

  • ValueError if forecast and hindcast embedding nets have different output sizes.

forward(data: Dict[str, Tensor]) Dict[str, Tensor]

Perform a forward pass on the SequentialForecastLSTM model.

Parameters:

data (Dict[str, torch.Tensor]) – Dictionary, containing input features as key-value pairs.

Returns:

Model outputs and intermediate states as a dictionary.
  • lstm_output_hindcast: Output sequence from the hindcast LSTM.

  • lstm_output_forecast: Output sequence from the forecast LSTM.

  • h_n_hindcast: Final hidden state of the hindcast model.

  • c_n_hindcast: Final cell state of the hindcast model.

  • h_n_forecast: Finall hidden state of the forecast model.

  • c_n_forecast: Final cell state of the forecast model.

  • y_hat: Predictions over the sequence from the head layer.

Return type:

Dict[str, torch.Tensor]

module_parts = ['hindcast_embedding_net', 'forecast_embedding_net', 'lstm', 'head']