Skip to content

moghadas76/Freq_Spect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FreqFlow: Long-term forecasting using lightweight flow matching

pic1_rev Screenshot from 2025-12-10 10-13-09

Abstract

We present SpectFlow, a novel deep learning architecture that combines frequency-domain interpolation with flow matching for long-term multivariate time series (MTS) forecasting. Our approach leverages the observation that longer time series provide finer frequency resolution, enabling more precise modeling of temporal dependencies. SpectFlow operates by transforming input sequences to the frequency domain via the Real Fast Fourier Transform (rFFT), performing complex-valued linear interpolation to extend the forecast horizon, and applying flow matching to learn velocity fields that capture residual dynamics. The model integrates channel-wise multi-head attention to capture inter-variate correlations and employs reversible instance normalization for stable training. Extensive experiments on multiple datasets demonstrate that SpectFlow achieves competitive performance while maintaining computational efficiency. The frequency-domain approach naturally handles both trend and seasonal components, while the flow matching mechanism refines predictions by modeling complex temporal dynamics.

Keywords: Time Series Forecasting, Flow Matching, Frequency Domain, Fourier Transform, Deep Learning

1. Introduction

Long-term multivariate time series forecasting remains a challenging problem in machine learning, with applications spanning from financial markets to climate modeling and traffic prediction. Traditional approaches often struggle to capture both short-term fluctuations and long-term trends while maintaining computational efficiency. Recent advances in deep learning have shown promising results, but many methods face limitations in handling extended forecast horizons and complex inter-variate dependencies.

The key insight driving our work is that time series contain structured frequency components corresponding to trends, seasonality, and residual patterns. By operating in the frequency domain, we can leverage the mathematical properties of Fourier transforms to naturally extend forecast horizons through interpolation. Furthermore, we observe that frequency-domain representations offer a compact and interpretable space for modeling temporal dynamics.

Our main contributions are:

  1. SpectFlow Architecture: A novel frequency-domain neural architecture that combines complex-valued linear interpolation with flow matching for time series forecasting.

  2. Flow Matching in Frequency Domain: The first application of flow matching techniques to frequency-domain time series representations, enabling effective modeling of temporal velocity fields.

  3. Channel-Aware Processing: Integration of multi-head attention mechanisms to capture inter-variate correlations in multivariate time series.

  4. Comprehensive Evaluation: Extensive experiments demonstrating competitive performance across multiple benchmarks with efficient computational requirements.

##2. Related Work

###2.1 Time Series Forecasting in Deep Learning

Recent deep learning approaches for time series forecasting can be broadly categorized into several paradigms. Transformer-based models like Informer and Autoformer have shown success by adapting attention mechanisms for temporal modeling. However, these approaches often face quadratic complexity issues for long sequences.

Linear models such as DLinear and NLinear have surprisingly demonstrated competitive performance by decomposing time series into trend and seasonal components. FEDformer and Film introduce frequency-domain processing but primarily focus on attention mechanisms rather than flow-based modeling.

2.2 Frequency-Domain Analysis

Frequency-domain approaches leverage the Fast Fourier Transform (FFT) to analyze time series in the spectral domain. The key advantage is that global patterns like trends and seasonality correspond to low-frequency components, while noise and irregularities manifest as high-frequency components. This natural decomposition enables effective filtering and interpolation.

###2.3 Flow Matching and Generative Models

Flow matching represents a recent advancement in generative modeling, providing a stable alternative to diffusion models. By learning velocity fields that transport between distributions, flow matching enables efficient and controllable generation. Our work represents the first application of these techniques to time series forecasting in the frequency domain.

3. Methodology

3.1 Preliminaries

3.1.1 The Fourier Transform in the Complex Frequency Domain

The Fast Fourier Transform (FFT) efficiently computes the Discrete Fourier Transform (DFT), converting discrete-time signals from the time domain to the complex frequency domain. For real-valued signals, the Real FFT (rFFT) maps an input sequence of $N$ real values to $N/2+1$ complex numbers.

In Fourier analysis, each frequency component is represented by a complex number encoding both amplitude (magnitude) and phase:

$$X(f) = |X(f)| e^{j\theta(f)} = |X(f)| (\cos{\theta(f)} + j \sin{\theta(f)})$$

where $X(f)$ is the frequency component at frequency $f$, $|X(f)|$ is its amplitude, and $\theta(f)$ is its phase.

A key property is that time shifts in the signal correspond to linear phase shifts in the frequency domain, while amplitude $|X(f)|$ remains unchanged. This enables modeling both amplitude scaling and phase shifting through complex multiplication.

3.1.2 Flow Matching

Flow matching learns a time-dependent velocity field $u_\theta(x_t, t)$ that transports a simple base distribution $p_0$ into a target data distribution $p_1$ along a continuous path. The dynamics are governed by:

$$\frac{d x_t}{d t} = u_\theta(x_t, t)$$

For linear interpolation $x_t = (1-t)x_0 + t x_1$, the training objective becomes:

$$\mathcal{L}_{\text{flow}}(\theta) = \mathbb{E}_{t \sim \mathcal{U}[0,1],, x_0 \sim p_0,, x_1 \sim p_1} \left[ | u_\theta(x_t, t) - (x_1 - x_0) |^2 \right]$$

###3.2 The SpectFlow Pipeline

SpectFlow Architecture

Figure 1: The SpectFlow pipeline showing the complete processing flow from input time series through frequency-domain interpolation to final forecasts.

Our model exploits the observation that multivariate time series contain trend, seasonal, and residual components. The frequency interpolation head captures trend and seasonality, while the flow matching head learns to refine predictions through accurate residual estimation.

The deterministic forecasting pipeline proceeds as follows:

  1. Channel-wise Attention: Inter-series correlations are computed using Multi-Head Attention (MHA)
  2. Frequency Transform: Time series segments are transformed via rFFT
  3. Complex Interpolation: A complex-valued linear layer performs frequency-domain interpolation
  4. Inverse Transform: Results are mapped back via inverse rFFT (irFFT)

To handle non-zero means, we apply reversible instance normalization (RIN), ensuring zero-mean inputs and excluding dominant DC components from the spectrum.

###3.3 Novel Mechanisms of SpectFlow

3.3.1 Multivariate Spatio-Temporal Processing

Our model assumes input time series contain $v$ variates with high spatiotemporal correlation. This enables better capture of relationships across multiple correlated variables and leverages dependencies for improved forecasting accuracy.

3.3.2 Flow Matching in the Frequency Domain

A key innovation is applying flow matching in the frequency domain to model velocity fields between consecutive time points. The model learns velocity field $u(x_t, t)$ describing transformation from noise spectrum to target spectrum, enabling efficient transformation and interpolation of frequency components.

3.3.3 Complex Frequency Linear Interpolation

The output length $L_o$ is controlled relative to input $L_i$ by interpolation rate $\eta = L_o / L_i$. Since rFFT maps length-$L$ series to $L/2$ frequency coefficients (after RIN), this rate directly scales the spectrum. A frequency band $[0, f]$ in input maps to $[0, \eta f]$ in output.

3.3.4 Low-Pass Filter (LPF)

The LPF reduces complexity by retaining only frequencies below a cutoff frequency (COF), preserving low-frequency structure while discarding high-frequency noise. We adopt a heuristic based on harmonic content, including sufficient harmonics to preserve periodic structure.

3.4 Architecture Details

3.4.1 Channel-wise Multi-Head Attention

# Channel attention mechanism
self.chan_qkv_in = nn.Linear(1, self.chan_attn_dim)
self.chan_attn = nn.MultiheadAttention(
    self.chan_attn_dim, 
    self.chan_attn_heads, 
    batch_first=True
)

The channel attention captures inter-variate dependencies by processing each time step across all channels using multi-head attention.

3.4.2 Frequency Domain Processing

# Frequency domain transformation
low_specx = torch.fft.rfft(x, dim=1)
low_specx = torch.view_as_real(low_specx[:, 0:self.cut_freq, :])

Complex-valued linear layers handle real and imaginary components separately while preserving complex multiplication properties:

# Complex multiplication simulation
low_specxy_real = self.freq_upsampler_real(low_specx_real) - \
                  self.freq_upsampler_imag(low_specx_imag)
low_specxy_imag = self.freq_upsampler_real(low_specx_imag) + \
                  self.freq_upsampler_imag(low_specx_real)

3.4.3 Flow Head Architecture

class TimeEmbed(nn.Module):
    def __init__(self, dim: int = 16):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(1, 32), 
            nn.SiLU(), 
            nn.Linear(32, dim)
        )

The flow head predicts velocity fields through a simple MLP that combines temporal embeddings with frequency-domain features.

3.5 Training and Inference

3.5.1 Training Procedure

Algorithm 1: Training SpectFlow with Flow Head
Input: Training dataset D = {(x_i, t_i)}
Hyperparameters: Learning rate η, batch size B, regularization λ_reg

1. Initialize optimizer with learning rate η
2. For each training step:
   a. Sample mini-batch B ⊂ D
   b. For each (x_i, t_i) ∈ B:
      - Compute rFFT of x_i
      - Apply flow head to predict velocity field u_pred,i
      - Apply frequency interpolation and return x'_pred,i via irFFT
   c. Compute reconstruction loss: L_recon = (1/B) Σ ||x'_pred,i - x_i||²
   d. Compute flow loss: L_flow = (1/B) Σ ||u_pred,i - u_target,i||²
   e. Total loss: L_total = λ_recon L_recon + λ_flow L_flow + λ_reg Σ||θ_p||²
   f. Update parameters via backpropagation

3.5.2 Inference Procedure

Algorithm 2: SpectFlow Inference
Procedure Infer(Input series x, trained model M):
1. X ← rFFT(x)                          # Frequency transform
2. X' ← LowPassFilter(X)                # Frequency filtering  
3. X_interpolated ← Upsampler(M, X')    # Frequency interpolation
4. x_reconstructed ← irFFT(X_interpolated) # Time domain reconstruction
5. x_final ← x_reconstructed + DC_offset   # Add back DC component
6. Return x_final

3.6 Loss Function

The loss function combines several components tailored for forecasting, reconstruction, and flow matching:

Mean Squared Error (MSE) Loss for reconstruction: $$\mathcal{L}{\text{reconstruction}} = \frac{1}{N} \sum{i=1}^N \left( \hat{x}_i - x_i \right)^2$$

Flow Matching Loss for velocity field prediction: $$\mathcal{L}{\text{flow}} = \frac{1}{N} \sum{i=1}^N \left( u_{\text{pred}, i} - u_{\text{target}, i} \right)^2$$

where $u_{\text{target}, i} = x_1 - x_0$ is the true velocity between consecutive time points.

Total Loss with regularization: $$\mathcal{L}{\text{total}} = \lambda{\text{rec}} \mathcal{L}{\text{reconstruction}} + \lambda{\text{flow}} \mathcal{L}{\text{flow}} + \lambda{\text{reg}} \sum_{p} | \theta_p |^2$$

4. Experimental Setup

4.1 Datasets

We evaluate SpectFlow on several benchmark datasets:

  • Brussels Traffic: 15-minute interval traffic data with 7 variates
  • ETT (Electricity Transforming Temperature): Hourly and minute-level datasets
  • Custom Datasets: Various domain-specific time series

4.2 Experimental Configuration

Based on the training script analysis:

# Example configuration for Brussels dataset
python run_longExp_F.py \
  --is_training 1 \
  --model Flow_FITS \
  --data Brussels \
  --seq_len 720 \
  --pred_len 96 \
  --flow_time_dim 64 \
  --flow_hidden_multiplier 0.626 \
  --loss flow \
  --learning_rate 0.00267 \
  --weight_decay 1.259841684694534e-06 \
  --batch_size 4

4.3 Hyperparameter Optimization

The implementation includes comprehensive hyperparameter optimization using Optuna:

# HPO configuration
def objective(trial):
    args.learning_rate = trial.suggest_float('learning_rate', 1e-5, 5e-3, log=True)
    args.weight_decay = trial.suggest_float('weight_decay', 1e-8, 1e-2, log=True)
    args.flow_time_dim = trial.suggest_categorical('flow_time_dim', [8, 16, 32, 64])
    args.flow_hidden_multiplier = trial.suggest_float('flow_hidden_multiplier', 0.5, 8.0, log=True)

Acknowledgments

Anonymous submission - acknowledgments omitted for review.

References

[References would be included in the actual submission but are omitted here for brevity]


Appendix

A. Implementation Details

The complete implementation is available with the following key components:

  1. Model Architecture (models/Flow_Spect.py): Core SpectFlow implementation
  2. Training Script (run_longExp_F.py): Comprehensive training pipeline with HPO
  3. Data Processing (data_provider/): Efficient data loading and preprocessing
  4. Evaluation (scripts/): Experimental configuration and evaluation scripts

B. Additional Experimental Results

[Additional tables and figures would be included here]

C. Hyperparameter Sensitivity Analysis

[Detailed analysis of hyperparameter effects would be included here]

D. Computational Complexity Analysis

The time complexity of SpectFlow is O(N log N) due to FFT operations, compared to O(N²) for transformer-based approaches, where N is the sequence length.


This anonymous submission presents SpectFlow, a novel frequency-domain flow matching approach for multivariate time series forecasting. The method demonstrates competitive performance while maintaining computational efficiency and providing interpretable frequency-domain representations.

Citation

cite by this:

@inproceedings{
moghadas2025frqflow,
title={Fr\`eqFlow: Long-term forecasting using lightweight flow matching},
author={Seyed Mohamad Moghadas and Bruno Cornelis and Adrian Munteanu},
booktitle={EurIPS 2025 Workshop on Principles of Generative Modeling (PriGM)},
year={2025},
url={https://openreview.net/forum?id=u4WTFzVmYs}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors