xnn.trfnn.models.equiformer.GraphAttention#
- class xnn.trfnn.models.equiformer.GraphAttention(irreps_in, irreps_sh, irreps_out, radial, irreps_head, num_heads, irreps_pre_attn=None, attention='mlp', nonlinear_message=True, rescale_degree=False, alpha_drop=0.0, proj_drop=0.0, avg_degree=15.57930850982666)[source]#
Bases:
ModuleEquivariant graph attention (section 4.2), or the dot-product attention of appendix C.3.
- Parameters:
irreps_in (e3nn.o3.Irreps or str) – Node, spherical-harmonic and output irreps.
irreps_sh (e3nn.o3.Irreps or str) – Node, spherical-harmonic and output irreps.
irreps_out (e3nn.o3.Irreps or str) – Node, spherical-harmonic and output irreps.
radial (list of int) – Widths of the radial function,
[n_rbf, hidden...].irreps_head (e3nn.o3.Irreps or str) – The value irreps of one head.
num_heads (int) – Number of heads.
irreps_pre_attn (e3nn.o3.Irreps or str, optional) – Irreps of the merged edge feature, by default
irreps_in.attention (str, optional) –
"mlp"(default) or"dot_product".nonlinear_message (bool, optional) – Non-linear values (MLP attention only), by default True.
rescale_degree (bool, optional) – Multiply the aggregated messages by the number of neighbors.
alpha_drop (float, optional) – Dropout of the attention weights and of the output channels.
proj_drop (float, optional) – Dropout of the attention weights and of the output channels.
avg_degree (float, optional) – The degree normalization of
rescale_degreewith dot-product attention.
- Variables:
core (torch.nn.Module) – Computes the logits
(E, H)and values(E, H, irreps_head.dim)of every edge.
- forward(x, src, dst, sh, edge_scalars, envelope)[source]#
Attend over the incoming edges of every atom.
- Parameters:
x (Tensor) – Node features
(N, irreps_in.dim).src (Tensor) – Sending (neighbor
j) and receiving (centeri) atom of every edge.dst (Tensor) – Sending (neighbor
j) and receiving (centeri) atom of every edge.sh (Tensor) – Spherical harmonics of
r_j - r_i,(E, irreps_sh.dim).edge_scalars (Tensor) – Radial basis of the edge lengths
(E, n_rbf).envelope (Tensor, optional) – Smooth-cutoff weight per edge.
- Returns:
(N, irreps_out.dim).- Return type:
Tensor