ARLSTM

class neuralhydrology.modelzoo.arlstm.ARLSTM(cfg: Config)

Bases: BaseModel

An autoregressive LSTM.

This model assumes that the last entry in dynamic inpus (x_d) is an observation that is supposed to match target data lagged by an integer number of timesteps. If this data is missing (NaN), it is substituted for the model prediction at the same lag. The model adds an extra dynamic input that serves as a binary flag to indicate whether the autoregressive input at a particular timestep is from observation vs. simulation.

Parameters:

cfg (Config) – The run configuration.

forward(data: Dict[str, Tensor], h_0: Tensor = None, c_0: Tensor = None) Dict[str, Tensor]

Perform a forward pass on the Autoregressive LSTM model.

Parameters:

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

Returns:

Model outputs and intermediate states as a dictionary.
  • y_hat: model predictions of shape [batch size, sequence length, number of target variables].

  • lstm_output: full timeseries of the hidden states from the lstm [batch size, sequence length, hidden size].

  • h_n: hidden state at the last time step of the sequence of shape [batch size, 1, hidden size].

  • c_n: cell state at the last time step of the sequence of shape [batch size, 1, hidden size].

Return type:

Dict[str, torch.Tensor]