{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/between-linear-and-sinusoidal-rethinking-the","title":"Between Linear and Sinusoidal: Rethinking the Time Encoder in Dynamic Graph Learning","arxiv_id":"2504.08129","date":"2025-04-10","proceeding":null,"authors":["Hsing-Huan Chung","Shravan Chaudhari","Xing Han","Yoav Wald","Suchi Saria","Joydeep Ghosh"],"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 relationships between edge events. In this paper, we 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 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. These results can be readily used to positively impact the design choices of a wide variety of dynamic graph learning architectures. The experimental code is available at: https://github.com/hsinghuan/dg-linear-time.git.","url_abs":"https://arxiv.org/abs/2504.08129v1","url_pdf":"https://arxiv.org/pdf/2504.08129v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"between-linear-and-sinusoidal-rethinking-the","repo_url":"https://github.com/hsinghuan/dg-linear-time","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"graph-learning","task_name":"Graph Learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2504.08129","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2504.08129"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hsinghuan/dg-linear-time","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":7},"by_repo_kind":{"official":{"samples":7,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"f807899c31b8f5a8","entry":"analyze_inter_event_time","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"src/utils/analysis.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/src/utils/analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f807899c31b8f5a8"}},{"code_sha256_prefix":"ca4193751be8b08c","entry":"analyze_target_historical_event_time_diff","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"src/utils/analysis.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/src/utils/analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ca4193751be8b08c"}},{"code_sha256_prefix":"0aa425a40e03ff85","entry":"eval_loop","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"auxiliary/synthetic.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/auxiliary/synthetic.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0aa425a40e03ff85"}},{"code_sha256_prefix":"3f44d03be213cac2","entry":"get_attn_score","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"auxiliary/synthetic.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/auxiliary/synthetic.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3f44d03be213cac2"}},{"code_sha256_prefix":"4c52ffe606e7a450","entry":"get_idx_dataloader","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"src/utils/data.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/src/utils/data.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4c52ffe606e7a450"}},{"code_sha256_prefix":"9c3ed29314413343","entry":"get_neighbor_sampler","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"src/utils/data.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/src/utils/data.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9c3ed29314413343"}},{"code_sha256_prefix":"dff46a044e84aff7","entry":"train_loop","repo":"hsinghuan/dg-linear-time","repo_kind":"official","path":"auxiliary/synthetic.py","file_url":"https://github.com/hsinghuan/dg-linear-time/blob/HEAD/auxiliary/synthetic.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dff46a044e84aff7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}