xnn.gnn.models.painn#
PaiNN (Schuett, Unke, Gastegger, ICML 2021) – equivariant message passing.
A faithful implementation of the polarizable atom interaction neural network of
K. T. Schuett, O. T. Unke, M. Gastegger, “Equivariant message passing for the prediction of tensorial properties and molecular spectra”, ICML 2021 (arXiv:2102.03150),
built from the paper’s equations on the xnn abstractions
(make_radial_basis(),
CosineCutoff,
scatter_sum(), …).
Representation (paper section IV.A). Every atom carries F rotationally
invariant scalar features s_i and F equivariant vector features
v_i in R^3. The scalars start as a learned embedding of the nuclear
charge, s_i^0 = a_{Z_i}, the vectors as zero. T pairs of a message
and an update block (Fig. 2) then refine both, each adding a residual.
Message block (eq 7 and 8, Fig. 2b):
ds_i = sum_j phi_s(s_j) o W_s(r_ij)
dv_i = sum_j v_j o phi_vv(s_j) o W_vv(r_ij)
+ sum_j phi_vs(s_j) o W_vs(r_ij) r_ij / |r_ij|
where r_ij = r_j - r_i, the shared network phi = W silu(W s + b) + b
maps F to 3F features that are split three ways, and the filters
W(r) = W rbf(r) f_cut(r) are linear combinations of a radial basis times
the cosine cutoff. The paper’s basis is sin(n pi r / r_cut) / r,
1 <= n <= 20 (radial_basis="bessel"); the default is 20 Gaussians on
[0, r_cut], and any basis of
make_radial_basis() can be used.
Update block (eq 9 and 10, Fig. 2c):
ds_i = a_ss(s_i, |V v_i|) + a_sv(s_i, |V v_i|) <U v_i, V v_i>
dv_i = a_vv(s_i, |V v_i|) U v_i
with the linear (bias-free) maps U and V of the vector features and
the shared network a = W silu(W [s_i, |V v_i|] + b) + b from 2F to
3F features, split into a_vv, a_sv, a_ss.
Readout (Fig. 2a): E = sum_i W silu(W s_i + b) + b with widths F ->
F/2 -> 1, plus the per-atom standardization and per-element reference of
every xnn model (energy_scale, energy_shift, atom_ref).
Tensorial properties (section IV.B). With dipole=True the dipole moment
is built from latent charges (eq 12, the default), computed from the scalars
by an atom-wise network F -> F/2 -> 1:
mu = sum_i q_i(s_i) r_i
or, with atomic_dipoles=True, from latent charges and atomic dipoles
(eq 13, the paper’s dipole model):
mu = sum_i mu_i(v_i) + q_i(s_i, v_i) r_i
and with polarizability=True the polarizability tensor from the rank-1
decomposition of eq 14:
alpha = sum_i alpha_i(s_i) I + nu_i(v_i) (x) r_i + r_i (x) nu_i(v_i),
where the scalars and vectors of eq 13 and 14 come from a stack of two gated
equivariant blocks (Fig. 3) and r_i are the positions relative to the center of mass
of the structure (the paper assumes the center of mass at the origin). The
latent charges are shifted so that they sum to the structure’s net charge
(total_charge, zero by default); correct_charges=False leaves them
unconstrained.
Conventions worth knowing:
xnn edge vectors are
pos[dst] - pos[src] = r_i - r_j; the paper’s directionr_ij / |r_ij|withr_ij = r_j - r_iis their negative, so the model flips the sign. The sign is observable only through the vector features (the dipoles and polarizabilities), not the energy.The norm in the update block is stabilized,
sqrt(|V v|^2 + epsilon)withepsilon = 1e-8, so that the gradient of an atom without neighbors (v = 0) is finite.The ablations of the paper’s Table IV are options:
scalar_product(the<U v, V v>term of eq 9) andvector_propagation(thev_j o phi_vvterm of eq 8).Weight sharing across the blocks is optional:
shared_filters(the same filters for every block) andshared_interactions(one set of message and update networks, with filters per block unless they are shared too).
Works for molecules and periodic systems through data.edge_vectors()
(the energy, forces and stress); the dipole and polarizability heads use
absolute positions and are meant for molecules.
Module Attributes
Edge count from which a PaiNN in evaluation mode recomputes the filters of each block in the backward pass instead of keeping them ( |
Classes
|
PaiNN interatomic potential with optional dipole and polarizability heads. |