xnn.krnn.common.sgdml_fit.fit_sgdml#
- xnn.krnn.common.sgdml_fit.fit_sgdml(model, graphs, sigma=None, lam=1e-10, perms=None, use_energy=True, energy_constraint=False, validation=None, max_symmetry_samples=1000, generator=None, solver='auto', tol=0.0001, n_inducing=None, max_memory=None, max_iter=None)[source]#
Fit a (s)GDML model to the forces (and energies) of its molecule.
- Parameters:
model (SGDML) – The model (fitted in place, in float64).
graphs (sequence of AtomicGraph) – Training structures with
forces(andenergy) labels.sigma (float or sequence of float, optional) – Kernel length scale; several values are compared by the force RMSE on
validation.Nonekeeps the model’s.lam (float, optional) – Regularization, by default 1e-10.
perms (array_like, optional) –
(Q, N)atom permutations to use. WhenNonethey are found from the training geometries if the model uses symmetries (find_permutations()), or the identity alone.use_energy (bool, optional) – Set the integration constant from the training energies, by default
True.energy_constraint (bool, optional) – Fit the energies together with the forces, by default
False.validation (sequence of AtomicGraph, optional) – Structures that choose among several
sigma.max_symmetry_samples (int, optional) – At most this many training geometries (a random subset) are matched to find the symmetries, by default 1000.
generator (torch.Generator, optional) – Random numbers of that subset and of the inducing geometries.
solver (str, optional) –
"analytic": a Cholesky factorization of the kernel matrix (exact);"cg": preconditioned conjugate gradients without the matrix (solve_iterative()), accurate totol;"auto"(the default): analytic when its matrix fits inmax_memory, otherwise iterative.tol (float, optional) – Relative residual at which the iterative solve stops, by default 1e-4.
n_inducing (int, optional) – Inducing geometries of the iterative solver’s preconditioner; by default as many as
max_memoryholds.max_memory (float, optional) – Memory in GB for the choice of the solver and the preconditioner; by default the device’s.
max_iter (int, optional) – Iteration limit of the iterative solve, by default ten times the number of unknowns.
- Returns:
model, fitted.- Return type: