Time2Vec: Learning a Vector Representation of Time
Seyed Mehran Kazemi, Rishab Goel, Sepehr Eghbali, Janahan Ramanan, Jaspreet Sahota, Sanjay Thakur, Stella Wu, Cathal Smyth, Pascal Poupart, Marcus Brubaker
TL;DR
This work tackles how to represent time within predictive models by introducing Time2Vec, a learnable vector embedding that combines a linear time term with multiple sine components. The representation is model-agnostic and designed to capture both periodic and non-periodic temporal patterns while being invariant to time rescaling. Across diverse datasets and architectures, Time2Vec improves performance over traditional time features, with learned frequencies providing interpretable and effective temporal encodings. The findings suggest Time2Vec as a practical tool for enhancing sequence and event-based models, with potential for broader theoretical and optimization-focused future work.
Abstract
Time is an important feature in many applications involving events that occur synchronously and/or asynchronously. To effectively consume time information, recent studies have focused on designing new architectures. In this paper, we take an orthogonal but complementary approach by providing a model-agnostic vector representation for time, called Time2Vec, that can be easily imported into many existing and future architectures and improve their performances. We show on a range of models and problems that replacing the notion of time with its Time2Vec representation improves the performance of the final model.
