AIModels.ClimLSTM module

ClimLSTM class for training, validation and prediction of a LSTM model for climate data.

Uses pytorch model libraries

class AIModels.ClimLSTM.TimeSeriesDataset(data, TIN, MIN, T, K)[source]

Bases: Dataset

Prepare Time Series data set for suitable for the pytorch Dataloader Set up for LSTM

Parameters:
  • data -- Data to be input

  • TIN -- input sequence length

  • MIN -- Input number of features

  • T -- Prediction sequence length

  • K -- Output Number of features

  • S -- Shift between input and target sequence

Note

A rigid shift in the data is produced to train on T time steps $x_1, x_2, ldots, x_{n-1}$ and the target is $x_2, x_3, ldots, x_{n}$ The size is already the number of expected forecasts step

class AIModels.ClimLSTM.ClimLSTM(num_classes, input_size, hidden_size, num_layers)[source]

Bases: Module

LSTM model for time series Based on pytorch

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

train_model(iterator, optimizer, criterion, scheduler, clip, device)[source]
evaluate_model(iterator, criterion, device)[source]
predict(iterator, K, Tpredict, device)[source]