SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2504.08129 · 2025

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

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2504.08129.json · badge: /api/ran/2504.08129.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
hsinghuan/dg-linear-time canonical (classifier label)
classifier basis not recorded on the link
5 ran · 2 no recorded run
FunctionStatusWhere it lives
analyze_inter_event_time Ran
ran on a synthesized input
hsinghuan/dg-linear-time/src/utils/analysis.py
code served (permissive licence) · get_code("f807899c31b8f5a8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create sample data for the function
# neighbor_times_list: list of arrays, each containing interaction times with neighbors
# node_interact_times: array of final interaction times for each node

# Create 3 nodes with varying numbers of neighbor interactions
neighbor_times_list = [
    np.array([1.0, 3.5, 7.2, 10.1]),  # node 0: 4 neighbor interactions
    np.array([2.1, 5.3, 8.9]),         # node 1: 3 neighbor interactions
    np.array([0.5, 2.8, 4.1, 6.7, 9.3])  # node 2: 5 neighbor interactions
]

# Final interaction times for each node (must match length of neighbor_times_list)
node_interact_times = np.array([12.5, 11.0, 11.8])

ARGS = {
    "neighbor_times_list": neighbor_times_list,
    "node_interact_times": node_interact_times
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
analyze_target_historical_event_time_diff Ran
ran on a synthesized input
hsinghuan/dg-linear-time/src/utils/analysis.py
code served (permissive licence) · get_code("ca4193751be8b08c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create small test data for the function
batch_size = 2
num_neighbors = 4

# Create node interaction times for current batch (shape: batch_size)
node_interact_times = np.array([100.0, 200.0])

# Create neighbor_times_list - list of arrays of historical interaction times for each node
# Node 0 has 3 historical interactions, Node 1 has 5 historical interactions
neighbor_times_list = [
    np.array([10.0, 25.0, 50.0]),
    np.array([30.0, 60.0, 90.0, 120.0, 150.0])
]

ARGS = {
    'neighbor_times_list': neighbor_times_list,
    'node_interact_times': node_interact_times,
    'num_neighbors': num_neighbors,
    'sample_neighbor_strategy': 'recent'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_loop Ran
ran on a synthesized input
hsinghuan/dg-linear-time/auxiliary/synthetic.py
code served (permissive licence) · get_code("0aa425a40e03ff85")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.utils.data import DataLoader

torch.manual_seed(0)

# Define a minimal model that satisfies the function's usage
class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
        self.get_attn_score = False
    
    def forward(self, t_diff, x):
        # Function expects model(t_diff, x) to return predictions
        # Combine inputs and pass through linear layer
        combined = x + t_diff  # element-wise addition
        return self.linear(combined)

# Create a minimal model instance
model = DummyModel()

# Define a loss criterion (binary cross entropy for classification)
criterion = nn.BCEWithLogitsLoss()

# Create a minimal dataloader
# Each batch should be (x, t_diff, y)
# x: shape (batch_size, feature_dim)
# t_diff: shape (batch_size, feature_dim)
# y: shape (batch_size,) with binary labels
batch_size = 2
feature_dim = 4

x_batch1 = torch.randn(batch_size, feature_dim)
t_diff_batch1 = torch.randn(batch_size, feature_dim)
y_batch1 = torch.randint(0, 2, (batch_size,))

x_batch2 = torch.randn(batch_size, feature_dim)
t_diff_batch2 = torch.randn(batch_size, feature_dim)
y_batch2 = torch.randint(0, 2, (batch_size,))

dataloader = [
    (x_batch1, t_diff_batch1, y_batch1),
    (x_batch2, t_diff_batch2, y_batch2),
]

# Set device to CPU
device = 'cpu'

# Define arguments dict
ARGS = {
    'model': model,
    'criterion': criterion,
    'dataloader': dataloader,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_attn_score Ran
ran on a synthesized input
hsinghuan/dg-linear-time/auxiliary/synthetic.py
code served (permissive licence) · get_code("3f44d03be213cac2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.get_attn_score = True
        self.linear = nn.Linear(4, 3)
    
    def forward(self, t_diff, x):
        # t_diff: (batch, seq_len)
        # x: (batch, seq_len, features)
        # Returns: (output, attn_score)
        batch_size = x.size(0)
        seq_len = x.size(1)
        attn_score = torch.randn(batch_size, seq_len, 2)
        output = self.linear(x.mean(dim=1))
        return output, attn_score

model = SimpleModel()

# Create a simple dataloader (list of batches)
# Each batch is (x, t_diff, y)
x1 = torch.randn(2, 3, 4)  # batch_size=2, seq_len=3, features=4
t_diff1 = torch.randn(2, 3)  # batch_size=2, seq_len=3
y1 = torch.randn(2, 3)  # batch_size=2, output_dim=3

x2 = torch.randn(2, 3, 4)
t_diff2 = torch.randn(2, 3)
y2 = torch.randn(2, 3)

dataloader = [
    (x1, t_diff1, y1),
    (x2, t_diff2, y2),
]

device = 'cpu'

ARGS = {
    'model': model,
    'dataloader': dataloader,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_idx_dataloader Ran
ran on a synthesized input
hsinghuan/dg-linear-time/src/utils/data.py
code served (permissive licence) · get_code("4c52ffe606e7a450")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataLoader. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch.utils.data import DataLoader, Dataset

torch.manual_seed(0)

class CustomizedDataset(Dataset):
    """Customized dataset for indices list."""

    def __init__(self, indices_list: list):
        super().__init__()
        self.indices_list = indices_list

    def __getitem__(self, idx: int):
        """Return the idx-th sample."""
        return self.indices_list[idx]

    def __len__(self):
        """Return the number of samples."""
        return len(self.indices_list)

def get_idx_dataloader(indices_list: list, batch_size: int, shuffle: bool):
    """Get dataloader of a dataset made of indices list."""
    dataset = CustomizedDataset(indices_list=indices_list)
    dataloader = DataLoader(dataset=dataset, batch_size=batch_size, shuffle=shuffle, drop_last=False)
    return dataloader

# Setup: create valid arguments
indices_list = [0, 1, 2, 3, 4, 5]
batch_size = 2
shuffle = True

ARGS = {
    "indices_list": indices_list,
    "batch_size": batch_size,
    "shuffle": shuffle
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_neighbor_sampler Not yet run
unverified (harvested, no recorded run)
hsinghuan/dg-linear-time/src/utils/data.py
code served (permissive licence) · get_code("9c3ed29314413343")
How it ran

no invocation recorded.

train_loop Not yet run
unverified (harvested, no recorded run)
hsinghuan/dg-linear-time/auxiliary/synthetic.py
code served (permissive licence) · get_code("dff46a044e84aff7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2504.08129")
get_code_for_paper("2504.08129")
have("2504.08129")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2504.08129.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2504.08129.svg)](https://syntology.ai/paper/2504.08129)

Connect an agent — have() is free.