TSDiff<T>

Models & Types · AiDotNet.Finance.Forecasting.Foundation

TSDiff — Self-Guiding Diffusion Models for Probabilistic Time Series Forecasting.

Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → ForecastingModelBase<T> → TimeSeriesFoundationModelBase<T> → TSDiff<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

TSDiff generates probabilistic forecasts using a three-step process: predict, refine, and synthesize. It first learns general time series patterns through diffusion (gradually adding and removing noise), then refines predictions using the model’s own internal guidance. This self-guided approach produces high-quality forecasts with well-calibrated uncertainty estimates.

How It Works

TSDiff uses unconditional denoising diffusion as a self-supervised pretraining objective with self-guided refinement for high-quality probabilistic forecasting.

Reference: Kollovieh et al., “Predict, Refine, Synthesize: Self-Guiding Diffusion Models for Probabilistic Time Series Forecasting”, NeurIPS 2023.

Example

// Create a TSDiff self-guiding diffusion model for probabilistic forecasting
// Three-step process: predict, refine, and synthesize with self-guided refinement
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputHeight: 512, inputWidth: 1, inputDepth: 1, outputSize: 24);
            
// Training mode with unconditional diffusion and self-guided refinement
var model = new TSDiff<double>(architecture);
            
// ONNX inference mode with pre-trained model
var onnxModel = new TSDiff<double>(architecture, "tsdiff.onnx");

Constructors

Constructor Summary
TSDiff(NeuralNetworkArchitecture<T> architecture, TSDiffOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)
TSDiff(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, TSDiffOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)

Properties

Property Summary
FoundationModelSize ModelSize { get; }
bool IsChannelIndependent { get; }
bool SupportsTraining { get; }
bool UseNativeMode { get; }
int MaxContextLength { get; }
int MaxPredictionHorizon { get; }
int NumFeatures { get; }
int PatchSize { get; }
int PredictionHorizon { get; }
int SequenceLength { get; }
int Stride { get; }

Methods

Method Summary
Dictionary<string, T> Evaluate(Tensor<T> predictions, Tensor<T> actuals)
Dictionary<string, T> GetFinancialMetrics()
ModelMetadata<T> GetModelMetadata()
Tensor<T> ApplyInstanceNormalization(Tensor<T> input)
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps)
Tensor<T> ForwardForTraining(Tensor<T> input) Tape-aware forward over the denoiser graph, at the noisiest step, from pure noise.