xnn.gnn.models.egt.EGTLayer#

class xnn.gnn.models.egt.EGTLayer(dim, heads=16, head_dim=16, ffn=(256, 2), activation='gelu', scale_by_degree=False)[source]#

Bases: Module

One local EGT layer: edge-biased, edge-gated multi-head attention between bonded atoms, pre-norm residual updates of nodes and edges.

Parameters:
  • dim (int) – Width of the node and edge channels.

  • heads (int) – Attention heads.

  • head_dim (int) – Width of each head’s queries, keys and values.

  • ffn (tuple of int) – (hidden, layers) of the node and edge feed-forward MLPs.

  • activation (str) – Activation of the feed-forward MLPs.

  • scale_by_degree (bool) – Multiply the attention weights by the receiving atom’s number of bonds.

forward(x, e, src, dst)[source]#

Updated nodes (n, dim) and edges (E, dim); edge k carries attention from atom src[k] to atom dst[k].

Parameters:
Return type:

tuple[Tensor, Tensor]