xnn.krnn.models.sgdml.SGDML#
- class xnn.krnn.models.sgdml.SGDML(species, sigma=10.0, kernel_order=2, use_symmetries=True, cutoff=1.0)[source]#
Bases:
InteratomicPotentialSymmetrized gradient-domain machine-learning force field.
The model is tied to its molecule: every structure must list the elements of
speciesin that order. It is filled byfit_sgdml()or loaded from an sGDML model file (load_sgdml_model()).- Parameters:
species (sequence of int or str) – The elements of the atoms, in order.
sigma (float, optional) – Length scale of the Matern kernel, by default 10.0.
kernel_order (int, optional) –
nof the Matern ordern + 1/2, by default 2.use_symmetries (bool, optional) – Find the permutational symmetries of the molecule when fitting (sGDML), by default
True;Falsegives GDML.cutoff (float, optional) – Neighbour-list radius of the data pipeline; the model reads positions only. By default 1.0.
- Variables:
train_desc (Tensor) –
(M, D)descriptors of the training geometries.train_weights (Tensor) –
(M, D)force coefficients through the descriptor Jacobians.energy_coef (Tensor) –
(M,)energy coefficients (empty unless energies were part of the fit).perms (Tensor) –
(Q, N)atom permutations of the symmetry group.c (std,) – Scale of the training forces and the integration constant.
lattice (Tensor) –
(3, 3)cell (rows as vectors) of a periodic model, empty otherwise.
- fit_options: Dict[str, object]#
options of
fit_closed_form()(from the config)
- fit_info: Dict[str, object]#
how the last fit was solved (the solver and, for the iterative one, its iterations and residual)
- set_permutations(perms)[source]#
Use the atom permutations
perms(Q, N)as the symmetry group.- Return type:
None
- receptive_field()[source]#
Unbounded: the energy reads every pair of atoms.
- Return type:
float | None
- geometry(data)[source]#
(B, N, 3)positions and(B, 3, 3)cells of the batch, in float64.The cell is the structure’s when it is periodic, otherwise the model’s own (a model fitted in a cell);
Nonefor molecules.- Parameters:
data (AtomicGraph)
- permuted_training_set()[source]#
(M, Q, D)training descriptors and weights under every permutation (cached).
- set_use_fast(use_fast)[source]#
Choose the implementation of the kernel expansion.
- Parameters:
use_fast (bool or str) –
"auto"(the default): the fused kernels (xnn.krnn.fast.sgdml) where they are available and measured to be faster (a CUDA device, Triton, a batch above the size crossover ofAUTO_POLICY, orAUTO_POLICY_TRAININGin training mode);True: wherever they are available;False: always the reference. The kernels give Hessians through the forces as the reference does.- Returns:
self.- Return type:
- forward(data)[source]#
Energy of each structure; the per-atom energies are its equal shares.
- Parameters:
data (AtomicGraph)
- Return type:
- forms_forces(data)[source]#
Whether
forward_direct()serves this evaluation: always in evaluation mode, unless the positions carry an autograd graph that the outputs must continue.- Parameters:
data (AtomicGraph)
- Return type:
- forward_direct(data)[source]#
forward()with the forces"forces"and"virial"(dE / d(strain)) of the paper’s force predictor: the gradient of the expansion by the descriptors, formed with the energy, through the descriptor Jacobian. The outputs carry no autograd graph.- Parameters:
data (AtomicGraph)
- Return type:
- fit(graphs, **kwargs)[source]#
Fit to labelled structures (see
fit_sgdml()).- Return type:
- fit_closed_form(train, validation=None)[source]#
The trainer’s fit:
fit()with the options of the config (fit_options).- Return type:
- classmethod from_config(cfg)[source]#
Build from
cfg.extra:species(one entry per atom, in order),sigma(a length scale, or several to choose from on the validation set when the trainer fits the model; by default 10 to 100 in steps of 10),kernel_order,use_symmetries, the fit optionslam,energy_constraint,use_energy,solver,solver_tol,n_inducingandmax_memory, ormodel_file(an sGDML model file to load);cfg.cutoffsizes the data pipeline’s graph.- Return type: