tglite.nn

class tglite.nn.TimeEncode(dim_time: int)
__init__(dim_time: int)

Initializes the TimeEncode module, which encodes time information into a higher-dimensional space.

Parameters:

dim_time – dimensionality of the encoded time

zeros(size: int, device)

Generates a tensor of zeros with the encoded time dimensionality.

Parameters:
  • size

  • device

forward(ts: Tensor) Tensor

Forward pass of the TimeEncode module. Encodes the input time stamps into a high-dimensional space.

Parameters:

ts – input time stamps

class tglite.nn.TemporalAttnLayer(ctx: TContext, num_heads: int, dim_node: int, dim_edge: int, dim_time: int, dim_out: int, dropout=0.1)
__init__(ctx: TContext, num_heads: int, dim_node: int, dim_edge: int, dim_time: int, dim_out: int, dropout=0.1)

Initializes the Temporal Attention Layer for processing dynamic graphs with temporal features. This layer uses multi-head attention mechanism to incorporate node, edge, and time features.

Parameters:
  • ctx – context object

  • num_heads – number of heads

  • dim_node – dimension of node features

  • dim_edge – dimension of edge features

  • dim_time – dimension of time features

  • dim_out – dimension of output features

  • dropout – dropout rate

forward(blk: TBlock) Tensor

Forward pass of the Temporal Attention Layer. Applies a time-sensitive attention mechanism over the input graph block (blk) to produce node embeddings. The method handles both cases of graph blocks with and without edges.

If the block has no edges, a zero-initialized tensor is concatenated with the destination node features. For blocks with edges, the method computes attention scores and aggregates neighbor features using the computed attention.

Parameters:

blk – input graph block