Loss#

We support two major categories of loss functions, along with several additional custom losses. Users can also easily define and integrate their own loss functions when needed.

Example#

# Loss Type 1
# - In most cases, if training is stable (no strong oscillation),
#   it is recommended to use MSE for all loss terms.
# - If noticeable oscillations or outliers appear during training,
#   consider switching the corresponding terms to Huber loss.
# - When energy weight is fixed to 1.0:
#     * forces weight: typically in the range [1, 10]
#     * stress weight: typically in the range [0.5, 10]
# - For other physical quantities, loss weights must be tuned by yourself
loss:
  _target_: tace.utils.loss.NormalLoss
  loss_property: [energy, forces, stress]
  # loss_property: [energy, forces, stress, polarization, conservative_polarizability, bonn_effective_charges]
  loss_function_name:  # prefix can be one of ["mse", "huber", "mae"]
    - mse_energy_per_atom
    - mse_forces
    - mse_stress
  loss_property_weights: [1, 8, 8]
  loss_huber_delta: 0.01 # float or List[float]
  # loss_property_weights: [1, 1, 1, 1, 1000, 1]

# # Loss Type 2
# # This loss does not require manually specified weights.
# # All loss weights should be set to 1.0, as they will be
# # automatically adjusted during training.
# #
# # Note:
# # Although convenient, the final convergence quality is
# # generally inferior to that achieved with well-tuned
# # manually assigned weights. This loss is therefore mainly
# # intended for toy experiments.
# loss:
#   _target_: tace.utils.loss.UncertaintyLoss
#   loss_property: [energy, forces, stress]
#   loss_function_name:
#     - mse_energy_per_atom
#     - mse_forces
#     - mse_stress
#   loss_property_weights: [1, 1, 1]
#   loss_huber_delta: 0.01 # float or List[float]

Notes#

  • Choice of loss function name:

    • For properties that are already per-atom quantities, the per_atom suffix is not required and is not supported.

    • In general, mean squared error (MSE) performs better than mean absolute error (MAE) during training. For training on large datasets (uMLIPs), we recommend using the huber loss.