Conditional Generation of Periodic Signals with Fourier-Based Decoder

Jiyoung Lee, Wonjae Kim, Daehoon Gwak, Edward Choi

TL;DR

Generating realistic periodic signals like electrocardiograms (ECGs) is notoriously difficult for standard sequential neural networks, which often diverge, collapse, or smooth over crucial fine details. This paper introduces a Conditional Variational Autoencoder (CVAE) architecture where the decoder directly predicts Fourier series coefficients rather than raw time-series points. By synthesizing signals as linear combinations of sinusoidal bases, the model generates diverse, high-fidelity, irregularly sampled periodic data that outclasses standard recurrent, transformer, and neural process baselines.

What Problem Does This Paper Address?

Periodic signals are ubiquitous in the physical and biomedical domains—vital examples include body temperature and ECG readings. Accurately generating synthetic ECGs conditioned on clinical diagnoses can mitigate severe data scarcity and class imbalance for rare cardiac conditions.

However, existing deep generative models struggle with periodicity:

  • Recurrent Neural Networks (RNNs) and Transformers often collapse into flat lines, diverge, or exhibit minimal sample diversity.
  • Continuous-time models like Neural ODEs (NODEs) and Neural Processes (NPs) over-smooth signals, missing high-frequency, clinically critical oscillations (such as fibrillatory waves).
  • Classical Discrete Fourier Transforms (DFT/DFS) are mathematically unsuited for irregular time grids, noise, and conditional generative modeling.

The authors set out to build an architecture capable of learning periodic signals with irregular sampling and fine-grained variations without suffering from optimization instabilities.

Methods

The authors adopt a Conditional Variational Autoencoder (CVAE) framework, but radically rethink how the decoder reconstructs time series:

[Input: x, t, c] -> [Encoder E_θ] -> z ~ N(μ, σ)
                                        │
           ┌────────────────────────────┴────────────────────────────┐
           ▼                                                         ▼
    ([z; c] + B_ψ^0)                                          ([z; c] + B_ψ^n)
           │                                                         │
     [Decoder D_φ]                                             [Decoder D_φ]
           │                                                         │
        (a0, b0)                  ...                             (an, bn)
           └────────────────────────────┬────────────────────────────┘
                                        ▼
             f̂(t) = Σ [ a_k cos(2πkt) + b_k sin(2πkt) ]
  1. Encoder ($E_\theta$): A 5-layer 1D Convolutional Neural Network processes a sequence of concatenated values, observation times, and class labels: $x^*_{t_i} = [x_{t_i}; t_i; c]$, mapping them to a latent distribution $q(z \mid X^*_T) = \mathcal{N}(\mu_z, \operatorname{diag}(\sigma_z))$.
  2. Latent Conditioning: The latent variable $z$ is sampled and concatenated with the class label $c$ to form $z^* = [z; c]$.
  3. Basis Embedding & Shared Decoder ($D_\phi$): The authors define a learnable basis lookup table $B_\psi \in \mathbb{R}^{n \times (z + n_c)}$, where each vector $B_\psi^k$ represents the $k$-th harmonic frequency. The model adds $B_\psi^k$ to $z^*$ in parallel across all $n$ harmonics and feeds each through a shared 6-layer MLP decoder to predict Fourier coefficients $a_k$ and $b_k$.
  4. Analytic Reconstruction: Rather than predicting point-by-point values sequentially, the signal is reconstructed analytically for any continuous time $t$ via the truncated Fourier series: $$\hat{f}(t) = \sum_{k=0}^n \left( a_k \cos(2\pi kt) + b_k \sin(2\pi kt) \right)$$ (assuming a normalized period $P=1$).

Datasets

The authors evaluate their approach on two benchmarks:

  • Synthetic Toy Sinusoid Dataset: 100,000 samples (80k train, 20k val/test) generated from mixtures of three sine and cosine waves with added Gaussian noise. Samples are divided into four classes varying across amplitude and frequency (Low/High Amplitude $\times$ Low/High Frequency).
  • PhysioNet Challenge 2021 (ECG): Real 12-lead ECG recordings. The authors extract 1-second windows (500 timesteps) from lead V6 across 36,110 recordings exhibiting three diagnosis classes: Right Bundle Branch Block (RBBB; 19,425 samples), Left Bundle Branch Block (LBBB; 5,270 samples), and Atrial Fibrillation (AF; 11,415 samples).

Key Insights and Ideas

  • Inductive Bias Matters: Previous Fourier Neural Networks attempted to use $\sin(x)$ or $\cos(x)$ as non-linear activation functions inside deep networks, which plagued training with non-monotonic loss landscapes and severe local minima. By keeping the network activations standard and using Fourier basis functions strictly as the analytic output aggregation layer, optimization remains smooth and well-behaved.
  • Continuous-Time Imputation "For Free": Because the decoder outputs continuous-time functional parameters ($a_k, b_k$), querying the signal at missing or irregularly spaced timesteps requires no recurrent unrolling—simply evaluate $\hat{f}(t)$ at the desired coordinates.
  • Preserving Micro-Phenomena: Baselines like NPs and NODEs optimize for global curve smoothness, effectively treating high-frequency features as noise. The Fourier decoder explicitly reserves distinct capacity ($a_k, b_k$) for high-frequency harmonics, capturing fine clinical details.

Key Results

The model was tested against GRU, Transformer, Neural ODE (NODE), and Neural Process (NP) decoders under 20% random temporal subsampling:

  • Reconstruction and Imputation MSE:
  • Toy Dataset: The Fourier decoder achieved an MSE of 0.649 (reconstruction) and 0.686 (imputation), significantly outperforming NP (3.813 / 4.615), NODE (15.905 / 19.896), and Transformer/GRU (>70 MSE).
  • ECG Dataset: The proposed method achieved an MSE of 2.164 / 1.519, besting NP (2.630 / 1.840) and NODE (4.937 / 3.262).
  • Conditional Generation Fidelity:
  • When evaluating generated ECG samples with an ensemble of pre-trained diagnosis classifiers, the Fourier decoder reached the highest overall accuracy (0.730) and F1 score (0.734).
  • In Atrial Fibrillation (AF), the Fourier decoder achieved an F1 score of 0.691 (recall 0.710), compared to NP's 0.631 and NODE's 0.309. Visual inspection confirmed the Fourier decoder was the only architecture capable of synthesizing the rapid, subtle f-waves characteristic of AF along with distinct R-peak morphology.

Limitations and Future Work

  • Fixed Period Assumption: The current formulation assumes all signals are normalized to a constant period of $P=1$. Adapting to signals with variable, time-varying, or unknown fundamental frequencies is left for future work.
  • Scalability to Multi-Lead / Multi-Dimensional Signals: Experiments were restricted to single-lead (V6) ECG cutouts; expanding to multi-channel, multi-periodic systems remains an open challenge.
  • Hyperparameter Sensitivity of Basis Count ($n$): The number of frequency harmonics $n$ must be chosen beforehand, requiring prior domain knowledge about the maximum frequency components present in the target data.

Summary updated

BibTeX
@inproceedings{lee2021conditional,
  author = {Jiyoung Lee and Wonjae Kim and Daehoon Gwak and Edward Choi},
  title = {{Conditional Generation of Periodic Signals with Fourier-Based Decoder}},
  booktitle = {DGMs Applications @ NeurIPS},
  year = {2021},
  url = {https://openreview.net/forum?id=y9Sxt1Lpyw},
}

Loading related content...

Figure