Between Linear and Sinusoidal: Rethinking the Time Encoder in Dynamic Graph Learning

Hsing-Huan Chung, Shravan Chaudhari, Xing Han, Yoav Wald, Suchi Saria +1 more
4/10/2025
cs.LGcs.SI

No official code found. Best implementation: hsinghuan/dg-linear-time (3 stars, MIT, last commit 2025-05-10).

Abstract

Dynamic graph learning is essential for applications involving temporal networks and requires effective modeling of temporal relationships. Seminal attention-based models like TGAT and DyGFormer rely on sinusoidal time encoders to capture temporal dependencies between edge events. Prior work justified sinusoidal encodings because their inner products depend on the time spans between events, which are crucial features for modeling inter-event relations. However, sinusoidal encodings inherently lose temporal information due to their many-to-one nature and therefore require high dimensions. In this paper, we rigorously study a simpler alternative: the linear time encoder, which avoids temporal information loss caused by sinusoidal functions and reduces the need for high-dimensional time encoders. We show that the self-attention mechanism can effectively learn to compute time spans between events from linear time encodings and extract relevant temporal patterns. Through extensive experiments on six dynamic graph datasets, we demonstrate that the linear time encoder improves the performance of TGAT and DyGFormer in most cases. Moreover, the linear time encoder can lead to significant savings in model parameters with minimal performance loss. For example, compared to a 100-dimensional sinusoidal time encoder, TGAT with a 2-dimensional linear time encoder saves 43% of parameters and achieves higher average precision on five datasets. While both encoders can be used simultaneously, our study highlights the often-overlooked advantages of linear time features in modern dynamic graph models. These findings can positively impact the design choices of various dynamic graph learning architectures and eventually benefit temporal network applications such as recommender systems, communication networks, and traffic forecasting.

View on arXivView PDF

Code Implementations(1)

MIT
32Python, Jupyter NotebookJul 11, 20241 years agoMIT

Similar Papers

Cite this paper

@article{chung2025between,
  title  = {Between Linear and Sinusoidal: Rethinking the Time Encoder in Dynamic Graph Learning},
  author = {Hsing-Huan Chung and Shravan Chaudhari and Xing Han and Yoav Wald and Suchi Saria and Joydeep Ghosh},
  year   = {2025},
  eprint = {2504.08129},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.08129v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.08129.svg)](https://codeofpaper.com/paper/2504.08129)

Discussion