deepmd.dpmodel.loss.ener_spin#

Classes#

EnergySpinLoss

Loss on energy, real force, magnetic force and virial for spin models.

Module Contents#

class deepmd.dpmodel.loss.ener_spin.EnergySpinLoss(starter_learning_rate: float = 1.0, start_pref_e: float = 0.0, limit_pref_e: float = 0.0, start_pref_fr: float = 0.0, limit_pref_fr: float = 0.0, start_pref_fm: float = 0.0, limit_pref_fm: float = 0.0, start_pref_v: float = 0.0, limit_pref_v: float = 0.0, start_pref_ae: float = 0.0, limit_pref_ae: float = 0.0, enable_atom_ener_coeff: bool = False, loss_func: str = 'mse', intensive_ener_virial: bool = False, **kwargs: Any)[source]#

Bases: deepmd.dpmodel.loss.loss.Loss

Loss on energy, real force, magnetic force and virial for spin models.

Parameters:
starter_learning_ratefloat

The learning rate at the start of the training.

start_pref_efloat

The prefactor of energy loss at the start of the training.

limit_pref_efloat

The prefactor of energy loss at the end of the training.

start_pref_frfloat

The prefactor of real force loss at the start of the training.

limit_pref_frfloat

The prefactor of real force loss at the end of the training.

start_pref_fmfloat

The prefactor of magnetic force loss at the start of the training.

limit_pref_fmfloat

The prefactor of magnetic force loss at the end of the training.

start_pref_vfloat

The prefactor of virial loss at the start of the training.

limit_pref_vfloat

The prefactor of virial loss at the end of the training.

start_pref_aefloat

The prefactor of atomic energy loss at the start of the training.

limit_pref_aefloat

The prefactor of atomic energy loss at the end of the training.

enable_atom_ener_coeffbool

if true, the energy will be computed as sum_i c_i E_i

loss_funcstr

Loss function type: ‘mse’ or ‘mae’.

intensive_ener_virialbool

If true, the MSE energy and virial terms use intensive normalization, i.e. an additional normalization by the square of the number of atoms (1/N^2) instead of the legacy (1/N) behavior. This keeps those MSE loss terms consistent with per-atom RMSE reporting and less dependent on system size. This option does not change the MAE formulation, which is handled separately. The default is false for backward compatibility with models trained using deepmd-kit <= 3.1.3.

**kwargs

Other keyword arguments.

loss_func = 'mse'[source]#
starter_learning_rate = 1.0[source]#
start_pref_e = 0.0[source]#
limit_pref_e = 0.0[source]#
start_pref_fr = 0.0[source]#
limit_pref_fr = 0.0[source]#
start_pref_fm = 0.0[source]#
limit_pref_fm = 0.0[source]#
start_pref_v = 0.0[source]#
limit_pref_v = 0.0[source]#
start_pref_ae = 0.0[source]#
limit_pref_ae = 0.0[source]#
enable_atom_ener_coeff = False[source]#
intensive_ener_virial = False[source]#
has_e[source]#
has_fr[source]#
has_fm[source]#
has_v[source]#
has_ae[source]#
call(learning_rate: float, natoms: int, model_dict: dict[str, deepmd.dpmodel.array_api.Array], label_dict: dict[str, deepmd.dpmodel.array_api.Array], mae: bool = False) tuple[deepmd.dpmodel.array_api.Array, dict[str, deepmd.dpmodel.array_api.Array]][source]#

Calculate loss from model results and labeled results.

property label_requirement: list[deepmd.utils.data.DataRequirementItem][source]#

Return data label requirements needed for this loss calculation.

serialize() dict[source]#

Serialize the loss module.

classmethod deserialize(data: dict) EnergySpinLoss[source]#

Deserialize the loss module.