The structure of the code references the MOMENT forecasting tutorial, and the training/eval code from Time-Series-Library.
Currently tuned for the Stock and Demand datasets. Add more dataloaders and run_xx.py
scripts as necessary (though most datasets should follow the current run.py
workflow, which is to:
- pre-evaluate the out-of-the-box MOMENT model,
- train the MOMENT model through linear probing, and
- evaluate the trained model.
The code currently requires a small change in the MOMENT library to function properly. In the forecast
method of the MOMENT
class, add a .forecast
to the return variable, like so:
def forecast(
self, x_enc: torch.Tensor, input_mask: torch.Tensor = None, **kwargs
) -> TimeseriesOutputs:
batch_size, n_channels, seq_len = x_enc.shape
# ... MOMENT code ...
dec_out = self.head(enc_out) # [batch_size x n_channels x forecast_horizon]
dec_out = self.normalizer(x=dec_out, mode="denorm")
return TimeseriesOutputs(input_mask=input_mask, forecast=dec_out).forecast
This is so that the existing training/eval code is more in line with that from the Time-Series-Library. All MOMENT methods return a TimeSeriesOutputs
object, so this simplifies the output from the model (doesn't require appending .forecast
on every other output variable).