xnn.cnn.models.spherical.SphericalCNN#
- class xnn.cnn.models.spherical.SphericalCNN(species=(1, 6, 7, 8, 16), cutoff=10.0, radius=0.48, bandwidth=10, exponent=1.0, features=None, bandwidths=None, n_features=160, n_blocks=5, n_alpha=None, n_beta=2, n_gamma=2, max_beta=0.39269908169872414, normalization='batch', activation='relu', set_readout=None, cutoff_fn=None, readout_activation='ssp', energy_shift=0.0, energy_scale=1.0, atomic_energies=None)[source]#
Bases:
VoxelPotentialSpherical CNN interatomic potential (Cohen et al., ICLR 2018, Sec. 5.4).
Every atom’s environment is the stack of spherical signals of
SphericalGrid(the potential of the neighbors of each species on a sphere around the atom, sampled on the Driscoll-Healy grid of bandwidthbandwidth).len(features)SphericalResBlockblocks map it toSO(3)signals of decreasing bandwidth,so3_integrate()pools them into invariant per-atom features, and the shared readout gives the per-atom energies. The defaults are Table 3 of the paper: five blocks with 20, 40, 60, 80, 160 channels at bandwidths 10, 8, 6, 4, 2, batch normalization and ReLU. Withset_readoutthe paper’s DeepSet readout is used instead: the per-atom features pass through an MLP, are summed over the structure and mapped to the energy by a second MLP (the per-atom energy is then the structure’s energy divided by its atom count, plus the atom’s reference energy).- Parameters:
species (sequence of int, optional) – Atomic numbers with a potential channel, by default
(1, 6, 7, 8, 16)(the elements of QM7).cutoff (float, optional) – Neighbor-list radius of the potential sums (Angstrom), by default 10.0.
radius (float, optional) – Radius of the sphere around each atom (Angstrom), by default 0.48 (half the shortest interatomic distance of QM7, so no atom lies on a sphere).
bandwidth (int, optional) – Bandwidth of the input signals, by default 10.
exponent (float, optional) – Power of the inverse distance of the potential, by default 1 (the paper’s
1/|x - p|; the reference data script uses 2).features (sequence of int or None, optional) – Channels and output bandwidth of every block;
Nonederives them fromn_features,n_blocksandbandwidth(default_schedule()).bandwidths (sequence of int or None, optional) – Channels and output bandwidth of every block;
Nonederives them fromn_features,n_blocksandbandwidth(default_schedule()).n_features (int, optional) – Channels of the last block when
featuresisNone, by default 160.n_blocks (int, optional) – Number of blocks when
featuresisNone, by default 5.n_alpha (Optional[int]) – Filter support of the correlations (see
SphericalResBlock).n_beta (int) – Filter support of the correlations (see
SphericalResBlock).n_gamma (int) – Filter support of the correlations (see
SphericalResBlock).max_beta (float) – Filter support of the correlations (see
SphericalResBlock).normalization (str or None, optional) –
"batch"(default, the paper) orNone.activation (str, optional) – Activation inside the blocks, by default
"relu"(the paper).set_readout (sequence of int or None, optional) –
(phi_hidden, latent, psi_hidden)of the DeepSet readout, e.g. the paper’s(150, 100, 50);None(default) reads every atom out separately with the shared atom-wise readout.cutoff_fn (str or None, optional) –
"cosine"multiplies each neighbor’s potential by the cosine envelope atcutoff(continuous energies for dynamics);None(default) is the paper’s untruncated potential.readout_activation (str) – See
VoxelPotential.energy_shift (float) – See
VoxelPotential.energy_scale (float) – See
VoxelPotential.atomic_energies – See
VoxelPotential.
- Variables:
blocks (torch.nn.Sequential) – The ResNet blocks.
bandwidths (features,) – Channels and bandwidths of every block.
- forward(data)[source]#
Compute per-atom and total energies for a batch of structures.
- Parameters:
data (AtomicGraph) – Batched atomic graph.
- Returns:
"node_energy"(N,),"energy"(B,)and the pooled invariant"node_features"(N, n_features).- Return type:
- classmethod from_config(cfg)[source]#
Build a
SphericalCNNfrom a configuration object.cfg.cutoff,cfg.n_features(channels of the last block) andcfg.n_interactions(number of blocks) are the core fields;cfg.extramay setspecies,radius,bandwidth,exponent,features,bandwidths,n_alpha,n_beta,n_gamma,max_beta,normalization,activation,set_readout,cutoff_fn,readout_activation,energy_shift,energy_scaleandatomic_energies.- Return type: