Papers
Topics
Authors
Recent
Search
2000 character limit reached

First & Second Derivative Heatmaps (FSDH)

Updated 18 January 2026
  • FSDH is a technique that computes first and second derivative heatmaps from 1D time series, capturing sharp transitions and turning points.
  • It normalizes and stacks discrete derivatives into a 2D tensor for convolutional networks, enabling precise extraction of local edge-aware features.
  • Integrating FSDH within Times2D allows hybrid modeling that combines local transient patterns with periodic components to boost forecasting accuracy.

First and Second Derivative Heatmaps (FSDH) constitute a critical module in the Times2D architecture for time series forecasting, offering a principled approach to extracting local difference statistics by mapping 1D time series into structured 2D representations. These heatmaps provide fine-grained insight into non-stationarity by highlighting both sharp changes and turning points, fundamentally enabling 2D convolutional architectures to capture local, transient, or regime-shifting phenomena that purely frequency-based or spectral approaches might miss (Nematirad et al., 31 Mar 2025).

1. Mathematical Foundations

The FSDH module operates on a batch of multivariate time series X1D∈RB×S×NX_{1D} \in \mathbb{R}^{B \times S \times N}, where BB denotes batch size, SS temporal length, and NN the variable channels. The process involves two discrete derivative computations:

  • First derivative D1(t)D_1(t) (forward difference with zero-padding):

D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}

producing D1∈RB×S×ND_1 \in \mathbb{R}^{B \times S \times N}.

  • Second derivative D2(t)D_2(t) (applied to D1D_1 as above):

D2(t)=D1(t+1)−D1(t),{D2(0)=0, t=0,…,S−2D_2(t) = D_1(t+1) - D_1(t), \quad \begin{cases} D_2(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}

with BB0.

Due to the uneven scale arising from abrupt transitions, normalization is typically employed, either by scale-invariant normalization BB1 or zero-mean/unit-variance normalization

BB2

allowing for consistent convolutional feature extraction across series of diverse scales.

2. Heatmap Construction and 2D Representation

The normalized first and second derivatives BB3 and BB4 are stacked along a new axis to create a tensor BB5:

BB6

Within CNN conventions, BB7 adopts the layout BB8, treating the two derivative orders as distinct channels. This 2D encoding enables subsequent convolutional processing to leverage local patterns jointly across time (BB9) and feature (SS0) dimensions.

The typical FSDH transformation and convolutional encoding process is as follows:

Stage Input Shape Operation/Output
Compute SS1, SS2 SS3 SS4 each
Normalize/stack SS5 SS6
Conv2D layers (SS72-3) SS8 SS9
Weighted sum/linear projection NN0 NN1
Slicing/final head NN2 NN3

For convolution, standard hyperparameters are: kernel size NN4, stride 1, padding 1, typically 2-3 layers, with ReLU activation and BatchNorm2d. The final head consists of a NN5 convolution or a linear projection, optionally selecting the last NN6 time steps for step-wise forecasting.

3. Interpreting Derivative Heatmaps

The first and second derivative heatmaps are explicitly interpretable:

  • First derivative heatmap (NN7): Encodes sharp rises and falls; regions where NN8 is large denote abrupt local increases or decreases, characterizing edges and rapid regime changes.
  • Second derivative heatmap (NN9): Encodes turning points; sign changes in D1(t)D_1(t)0 localize inflection points such as local maxima or minima, highlighting corners in the temporal trajectory.

This local structure captures features—such as spikes, drops, and onset of transitions—often indistinguishable in frequency-decomposed or smoothed representations. FSDH thereby yields a two-channel 2D image from which convolutional operations can extract composite phenomena such as "edges" and "corners" in the time-value axis—a property known to be useful in standard computer vision convolutional processing (Nematirad et al., 31 Mar 2025).

4. Integration within Times2D Forecasting Pipeline

In the Times2D pipeline, FSDH and the Periodic Decomposition Block (PDB) operate in parallel, each generating a 1D summary tensor for the forecasting horizon:

  • FSDH produces D1(t)D_1(t)1 by projecting the feature maps via weighted sum or linear operation.
  • PDB yields an analogous tensor D1(t)D_1(t)2 that contains frequency-domain multi-period decomposed features.

These are combined in the Aggregation Forecasting Block (AFB) either by direct element-wise summation: D1(t)D_1(t)3 or, optionally, via gated/attention-based fusion with a learned scalar D1(t)D_1(t)4: D1(t)D_1(t)5

This mechanism can be viewed as a specialized residual fusion, maintaining the complementary statistical properties of both decomposition branches.

5. Implementation Specifics and Hyperparameter Regimes

Key hyperparameters and architectural conventions for FSDH in Times2D include:

  • Input shapes: D1(t)D_1(t)6 for the stacked derivatives; D1(t)D_1(t)7 is typically in D1(t)D_1(t)8.
  • Convolutional stack: 2 or 3 layers; kernel size D1(t)D_1(t)9; stride D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}0; padding to preserve dimensionality.
  • Channels: Input: D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}1, output per layer: e.g., D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}2.
  • Activation: ReLU, with BatchNorm2d.
  • Head: D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}3 convolution or linear projection D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}4; final slicing or linear to produce last D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}5 forecasted steps.
  • Optimization: All FSDH weights and parameters are trained end-to-end alongside the full Times2D model using either MSE or MAE on the final fused output.

The process is summarized in the following schematic pseudocode (PyTorch-style):

D1(t)=X1D(t+1)−X1D(t),{D1(0)=0, t=0,…,S−2D_1(t) = X_{1D}(t+1) - X_{1D}(t), \quad \begin{cases} D_1(0) = \mathbf{0}, \ t = 0, \dots, S-2 \end{cases}6

6. Empirical Role and Significance

The FSDH module, by explicitly representing both sharp local changes and turning points, enhances the Times2D framework’s capacity to model highly non-stationary, irregular, or rapidly fluctuating real-world time series. When combined in a residual fusion with the globally-informative, periodic components extracted by the PDB, FSDH yields a hybrid representation that empirically demonstrates state-of-the-art forecasting accuracy for both short-term transitions and long-horizon prediction tasks. This suggests that FSDH provides an effective means to supplement classical spectral or frequency-based features with local, edge-aware statistics directly extracted from the raw temporal data (Nematirad et al., 31 Mar 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to First and Second Derivative Heatmaps (FSDH).