InformerModel<T>
Models & Types · AiDotNet.TimeSeries
Implements the Informer model for efficient long-sequence time series forecasting.
Inheritance: TimeSeriesModelBase<T> → InformerModel<T>
Implements: IGeneratedParameterRegistrar<T>, ISupportsLossFunction<T>
For Beginners
Informer makes transformers practical for long time series forecasting. Regular transformers get very slow with long sequences because every time step looks at every other time step. Informer speeds this up by only looking at the most important connections (ProbSparse attention), compressing the sequence as it goes through layers, and predicting all future values at once instead of one at a time.
How It Works
The Long-Sequence Forecasting Problem: Traditional Transformer models achieve state-of-the-art results in many sequence modeling tasks, but they struggle with long time series because self-attention has O(L^2) time and memory complexity. For a sequence of 1000 time steps, vanilla attention requires 1 million operations per layer. This makes long-horizon forecasting computationally prohibitive.
The Informer Solution: Informer (Zhou et al., AAAI 2021) introduces three key innovations:
- ProbSparse Self-Attention (O(L log L) complexity)
- Self-Attention Distilling for sequence compression
- Generative-Style Decoder for parallel multi-step forecasting
This class forecasts a univariate series (the reference’s features='S') with the network the official code
builds (InformerNetwork, shared with the Finance Informer and checked against Informer2020), and
trains it as the reference’s experiment does. The temporal embedding needs timestamps, which the time-series
interface does not carry, so it is not used.
Example
using AiDotNet;
using AiDotNet.Data.Loaders;
using AiDotNet.TimeSeries;
using AiDotNet.Tensors.LinearAlgebra;
double[] series =
{
120, 135, 148, 160, 155, 170, 180, 195, 210, 198, 220, 235,
140, 155, 165, 178, 172, 190, 200, 215, 230, 218, 245, 260
};
var x = new Matrix<double>(series.Length, 1);
for (int i = 0; i < series.Length; i++) x[i, 0] = i;
var result = await new AiModelBuilder<double, Matrix<double>, Vector<double>>()
.ConfigureModel(new InformerModel<double>())
.ConfigureDataLoader(DataLoaders.FromMatrixVector(x, new Vector<double>(series)))
.BuildAsync();
var forecast = result.Predict(new Matrix<double>(6, 1));
Console.WriteLine($"InformerModel: forecast {forecast.Length} steps.");
Constructors
| Constructor | Summary |
|---|---|
InformerModel(InformerOptions<T> options) |
Initializes a new instance of the Informer model with the specified options. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
T PredictSingle(Vector<T> input) |
Predicts the value after the given history (its last LookbackWindow values). |
Vector<T> ForecastHorizon(Vector<T> input) |
Forecasts the ForecastHorizon values after the given history in one forward pass of the generative decoder. |
Vector<T> Predict(Matrix<T> input) |
Predicts the series: with as many rows as the training series, the one-step forecast of each observation from the values before it; with one column (time steps), the forecasts of the next input.Rows steps after the training series, continue… |
void SetLossFunction(ILossFunction<T> lossFunction) |