training_metrics

MAE of energy, MAE for gradient, MAE for proj_minao.

class MAEEnergy(mode='per molecule', sample_weigher: SampleWeigher | None = 'default')[source]

Metric for the mean absolute error of the kinetic energy. When mode="per molecule", the error is averaged as.

\[\text{MAE_Energy} = \frac{1}{\text{n_molecules}}\sum_d\sum_k | T_{S,\Theta}(\textbf{p}^{(d,k)},\mathcal{M^{(d)}})-T_S^{(d,k)}|.\]
update(batch: Batch, pred_energy: Tensor, projected_gradient_difference: Tensor, pred_diff: Tensor)[source]

Override this method to update the state variables of your metric class.

class MAEGradient(mode='per molecule', sample_weigher: SampleWeigher | None = 'default')[source]

Mean Absolute Error - Metric of the gradient of the kinetic energy averaged over the number of molecules.

For the default mode="per molecule", the error is averaged as

\[\text{MAE_Gradint} = \frac{1}{\text{n_molecules}}\sum_d\sum_k || \left( \textbf{I}-\frac{\textbf{w}^{(d)}{\textbf{w}^{(d)}}^T}{{\textbf{w}^{(d)}}^T \textbf{w}^{(d)}}\right)\left(\nabla_\textbf{p} T_{S,\Theta}(\textbf{p}^{(d,k)},\mathcal{M^{(d)}})- \nabla_\textbf{p} T_S^{(d,k)}\right)||.\]

For mode="per electron", the error is averaged as

\[\text{WMAE_Gradint} = \frac{1}{\text{n_molecules}}\sum_d \frac{1}{\text{n_electrons}^{(d)}}\sum_k || \left( \textbf{I}-\frac{\textbf{w}^{(d)}{\textbf{w}^{(d)}}^T}{{\textbf{w}^{(d)}}^T \textbf{w}^{(d)}}\right)\left(\nabla_\textbf{p} T_{S,\Theta}(\textbf{p}^{(d,k)},\mathcal{M^{(d)}}) -\nabla_\textbf{p} T_S^{(d,k)}\right)||.\]
update(batch: Batch, pred_energy: Tensor, projected_gradient_difference: Tensor, pred_diff: Tensor)[source]

Computes the error and updates the hidden states.

class MAEInitialGuess(mode='per molecule', sample_weigher: SampleWeigher | None = 'default')[source]

MAE of the initial guess delta coefficients.

update(batch: Batch, pred_energy: Tensor, projected_gradient_difference: Tensor, pred_diff: Tensor)[source]

Computes the error and updates the hidden states.

class PerSampleAbsoluteErrorMetric(mode='per molecule', sample_weigher: SampleWeigher | None = 'default')[source]

Base class for metrics that calculate the absolute error per sample.

__init__(mode='per molecule', sample_weigher: SampleWeigher | None = 'default')[source]
Parameters:
  • mode – The averaging mode, either “per molecule” or “per electron”.

  • sample_weigher (SampleWeigher, optional) – Sample weigher to be used. Defaults to DEFAULT_SAMPLE_WEIGHER.

compute()[source]

Calculates the mean error, based on the averaging mode.

compute_per_electron()[source]

Calculates the mean error per electron.

compute_per_molecule()[source]

Calculates the mean error per molecule.

update_with_errors(batch: Batch, errors: Tensor)[source]

Updates the hidden states for a batch and corresponding errors.

Parameters:
  • batch – The OFData object, used for updating the molecule and electron count.

  • errors – The errors that should be accumulated. The shape should either be (batch_size,) or (n_basis,), in the latter case the errors per basis function are summed up to get the error per molecule.