xnn.gnn.models.egt.MolecularGraphTransformer#
- class xnn.gnn.models.egt.MolecularGraphTransformer(atom_dim=32, feature_dim=8, node_mlp=(64, 256, 2), edge_mlp=(64, 256, 2), hidden=256, layers=4, heads=16, head_dim=16, ffn=(256, 2), out_dim=256, jumping_knowledge='cat', activation='gelu', scale_by_degree=False)[source]#
Bases:
ModuleAtom and bond hidden states of molecules from their two-dimensional graphs.
- Parameters:
atom_dim (int) – Embedding widths (see
GraphEmbedding).feature_dim (int) – Embedding widths (see
GraphEmbedding).node_mlp (tuple of int) –
(hidden, out, layers)of the embedding MLPs.edge_mlp (tuple of int) –
(hidden, out, layers)of the embedding MLPs.hidden (int) – Width of the attention layers.
layers (int) – Number of attention layers.
heads (int) – Attention heads and their width.
head_dim (int) – Attention heads and their width.
ffn (tuple of int) –
(hidden, layers)of the feed-forward MLPs.out_dim (int) – Width of the atom hidden states returned.
jumping_knowledge (str or None) –
"cat": the atom states are a linear map of every layer’s activated output, concatenated;"last": of the last one;None: the last layer’s output as is (hiddenmust then equalout_dim).activation (str) – Activation of every MLP and between the layers.
- Variables:
edge_dim (node_dim,) – Widths of the returned atom and edge states.
- forward(node_features, edge_features, edge_index, atom_class, edge_class)[source]#
Atom states
(n, node_dim)and directed-edge states(2 m, edge_dim)(both directions of a bond equal).- Parameters:
node_features (Tensor) –
(n, 5)integer atom features.edge_features (Tensor) –
(2 m, 2)integer bond features, one row per directed edge.edge_index (Tensor) –
(2, 2 m)source and target atoms; edges2 kand2 k + 1are the two directions of bondk.atom_class (Tensor) – Equivalence classes
(n,)and(2 m,)(the first member’s index).edge_class (Tensor) – Equivalence classes
(n,)and(2 m,)(the first member’s index).
- Returns:
The atom and edge states.
- Return type:
tuple of Tensor