xnn.trfnn.models.equiformer_v2.SO2GraphAttention#

class xnn.trfnn.models.equiformer_v2.SO2GraphAttention(channels, hidden_channels, num_heads, alpha_channels, value_channels, out_channels, lmax, mmax, radial, n_elements, use_atom_edge_embedding, use_m_share_rad, activation, use_attn_renorm, resolution, alpha_drop=0.0)[source]#

Bases: Module

Equivariant graph attention on eSCN convolutions (section 3.5, Figure 1b).

Parameters:
  • channels (int) – Node channels C.

  • hidden_channels (int) – Channels of the first SO(2) convolution (d_attn_hidden).

  • num_heads (int) – Heads and per-head widths of the attention scalars and values.

  • alpha_channels (int) – Heads and per-head widths of the attention scalars and values.

  • value_channels (int) – Heads and per-head widths of the attention scalars and values.

  • out_channels (int) – Output channels.

  • lmax (int) – Degrees and the orders kept in the edge frames.

  • mmax (int) – Degrees and the orders kept in the edge frames.

  • radial (list of int) – Widths of the radial function [n_in, hidden...].

  • n_elements (int) – Size of the element embeddings of the edges.

  • use_atom_edge_embedding (bool) – Embed the elements of the two atoms into the radial input.

  • use_m_share_rad (bool) – One radial weight per degree and channel, applied before the rotation.

  • activation (str) – "sep_s2" (separable S2, the paper’s), "s2" or "gate".

  • use_attn_renorm (bool) – Layer norm on the attention scalars (attention re-normalization).

  • resolution (int, optional) – Sphere samples of the S2 activation.

  • alpha_drop (float, optional) – Dropout of the attention weights.

forward(x, atomic_numbers, edge_rbf, src, dst, rot, rot_inv, envelope)[source]#

Attend over the incoming edges of every atom.

Parameters:
  • x (Tensor) – Node features (N, (L + 1)^2, C).

  • atomic_numbers (Tensor) – (N,).

  • edge_rbf (Tensor) – Distance basis of the edges (with the shared element embeddings, if any).

  • src (Tensor) – Sending (neighbor j) and receiving (center i) atom of every edge.

  • dst (Tensor) – Sending (neighbor j) and receiving (center i) atom of every edge.

  • rot (Tensor) – The rotations into the edge frames and back (_Rotations.matrices).

  • rot_inv (Tensor) – The rotations into the edge frames and back (_Rotations.matrices).

  • envelope (Tensor, optional) – Smooth-cutoff weight per edge.

Returns:

(N, (L + 1)^2, out_channels).

Return type:

Tensor