Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Training and Validation

General process of constructing a MLP.

General process of constructing a MLP.

Dataset: The Foundation of MLPs

A good machine learning potential (MLP) starts with a high-quality dataset. This dataset is typically generated using density functional theory (DFT) calculations and should include:

What Makes a Dataset Good?

Training: How MLPs Learn

Training an MLP involves teaching it to predict energies, forces, and stresses from atomic configurations. This process can be broken down into three main steps:

  1. Loss Function: The loss function measures how far the MLP’s predictions are from the actual values. A common choice is a weighted combination of mean squared error (MSE) terms for energies, forces, and stresses:

    L=wE1Ncfgi=1Ncfg(EiE^i)2+wF1Natomsi=1Ncfga=1niFiaF^ia2+wS1Ncfgi=1NcfgSiS^i2L = w_E \frac{1}{N_{\mathrm{cfg}}} \sum_{i=1}^{N_{\mathrm{cfg}}} \left( E_i - \hat{E}_i \right)^2 + w_F \frac{1}{N_{\mathrm{atoms}}} \sum_{i=1}^{N_{\mathrm{cfg}}} \sum_{a=1}^{n_i} \left\| \mathbf{F}_{ia} - \hat{\mathbf{F}}_{ia} \right\|^2 + w_S \frac{1}{N_{\mathrm{cfg}}} \sum_{i=1}^{N_{\mathrm{cfg}}} \left\| \mathbf{S}_i - \hat{\mathbf{S}}_i \right\|^2
    • NcfgN_{\mathrm{cfg}}: Number of configurations.

    • nin_i: Number of atoms in configuration ii.

    • Natoms=iniN_{\mathrm{atoms}} = \sum_i n_i: Total number of atoms in the dataset.

    • EiE_i, E^i\hat{E}_i: True and predicted energies.

    • Fia\mathbf{F}_{ia}, F^ia\hat{\mathbf{F}}_{ia}: True and predicted forces on atom aa in configuration ii.

    • Si\mathbf{S}_i, S^i\hat{\mathbf{S}}_i: True and predicted stress or virial quantities.

    • wEw_E, wFw_F, wSw_S: Weights used to balance the different error terms.

    In practice, these weights are important because energies, forces, and stresses have different units, magnitudes, and numbers of targets.

  2. Optimization: Algorithms like gradient descent are used to minimize the loss function, improving the model’s predictions over time.

  3. Hyperparameters: These are settings that control the training process, such as learning rate, batch size, and number of epochs. Tuning these hyperparameters is crucial for achieving optimal performance.

  4. Validation: To ensure the MLP generalizes well, test it on a separate validation dataset. This helps detect overfitting and ensures the model performs well on unseen data.

Evaluation: Measuring MLP Performance

Once the MLP is trained, it’s important to evaluate its performance. Here are some key aspects to consider:

  1. Accuracy:

    • Use metrics like Mean Absolute Error (MAE) and Root Mean Squared Error (RMSE) to assess:

      • Energy predictions (e.g., in meV/atom).

      • Force predictions (e.g., in eV/Å).

    • You also need to check the accuracy of the properties that you are interested in, such as ionic conductivity, etc.

  2. Stability in Molecular Dynamics (MD):

    • Test the MLP in MD simulations to check if it maintains stable temperature and conserves energy.

  3. Transferability:

    • Evaluate the MLP on new structures or chemistries not included in the training dataset. This ensures the model can handle scenarios it hasn’t seen before.