xnn.krnn.common.sgdml_fit.kernel_matrix#

xnn.krnn.common.sgdml_fit.kernel_matrix(model, x, u, energy_constraint=False, full=True)[source]#

The kernel matrix of the training set.

The force block of training geometries i and j is -sum_q [g_q J_i^T P_q J_j + t_q (J_i^T D_q) (D_q^T P_q J_j)] with D_q = x_i - P_q x_j. Every row of a descriptor Jacobian holds two atom blocks (u_d on atom a_d, -u_d on atom b_d), so J_i^T P_q J_j is a sum of 3x3 outer products u_i,d u_j,p(d)^T placed on the atom pairs, and J_i^T D_q and D_q^T P_q J_j are the rows scaled by D_q and summed onto atoms. Both placements are products with sparse matrices of +1 and -1. The matrix is symmetric when the permutations are closed under inversion; only the blocks j >= i are formed then.

Parameters:
  • model (SGDML) – Supplies the kernel and the permutations.

  • x (Tensor) – (M, D) training descriptors.

  • u (Tensor) – (M, D, 3) pair gradients of the descriptors (pair_gradients()).

  • energy_constraint (bool, optional) – Append the (negated) energy rows and columns.

  • full (bool, optional) – Fill the whole matrix (the default). False leaves the strict upper triangle of a symmetric matrix unset, which a Cholesky factorization does not read.

Returns:

(3NM, 3NM), or (3NM + M, 3NM + M) with energies.

Return type:

Tensor