deepmd.pt.loss.ener#

Classes#

EnergyStdLoss

Helper class that provides a standard way to create an ABC using

EnergyHessianStdLoss

Helper class that provides a standard way to create an ABC using

Functions#

custom_huber_loss(→ torch.Tensor)

Module Contents#

deepmd.pt.loss.ener.custom_huber_loss(predictions: torch.Tensor, targets: torch.Tensor, delta: float = 1.0) torch.Tensor[source]#
class deepmd.pt.loss.ener.EnergyStdLoss(starter_learning_rate: float = 1.0, start_pref_e: float = 0.0, limit_pref_e: float = 0.0, start_pref_f: float = 0.0, limit_pref_f: 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, start_pref_pf: float = 0.0, limit_pref_pf: float = 0.0, relative_f: float | None = None, enable_atom_ener_coeff: bool = False, start_pref_gf: float = 0.0, limit_pref_gf: float = 0.0, numb_generalized_coord: int = 0, loss_func: str = 'mse', inference: bool = False, use_huber: bool = False, use_default_pf: bool = False, f_use_norm: bool = False, huber_delta: float | list[float] = 0.01, intensive_ener_virial: bool = False, **kwargs: Any)[source]#

Bases: deepmd.pt.loss.loss.TaskLoss

Helper class that provides a standard way to create an ABC using inheritance.

loss_func = 'mse'[source]#
starter_learning_rate = 1.0[source]#
has_e[source]#
has_f[source]#
has_v[source]#
has_ae[source]#
has_pf[source]#
has_gf[source]#
start_pref_e = 0.0[source]#
limit_pref_e = 0.0[source]#
start_pref_f = 0.0[source]#
limit_pref_f = 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]#
start_pref_pf = 0.0[source]#
limit_pref_pf = 0.0[source]#
start_pref_gf = 0.0[source]#
limit_pref_gf = 0.0[source]#
use_default_pf = False[source]#
relative_f = None[source]#
enable_atom_ener_coeff = False[source]#
numb_generalized_coord = 0[source]#
inference = False[source]#
use_huber = False[source]#
f_use_norm = False[source]#
intensive_ener_virial = False[source]#
huber_delta = 0.01[source]#
forward(input_dict: dict[str, torch.Tensor], model: torch.nn.Module, label: dict[str, torch.Tensor], natoms: int, learning_rate: float, mae: bool = False) tuple[dict[str, torch.Tensor], torch.Tensor, dict[str, torch.Tensor]][source]#

Return loss on energy and force.

Parameters:
input_dictdict[str, torch.Tensor]

Model inputs.

modeltorch.nn.Module

Model to be used to output the predictions.

labeldict[str, torch.Tensor]

Labels.

natomsint

The local atom number.

Returns:
model_pred: dict[str, torch.Tensor]

Model predictions.

loss: torch.Tensor

Loss for model to minimize.

more_loss: dict[str, torch.Tensor]

Other losses for display.

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.

Returns:
dict

The serialized loss module

classmethod deserialize(data: dict) deepmd.pt.loss.loss.TaskLoss[source]#

Deserialize the loss module.

Parameters:
datadict

The serialized loss module

Returns:
Loss

The deserialized loss module

class deepmd.pt.loss.ener.EnergyHessianStdLoss(start_pref_h: float = 0.0, limit_pref_h: float = 0.0, **kwargs: Any)[source]#

Bases: EnergyStdLoss

Helper class that provides a standard way to create an ABC using inheritance.

has_h[source]#
start_pref_h = 0.0[source]#
limit_pref_h = 0.0[source]#
forward(input_dict: dict[str, torch.Tensor], model: torch.nn.Module, label: dict[str, torch.Tensor], natoms: int, learning_rate: float, mae: bool = False) tuple[dict[str, torch.Tensor], torch.Tensor, dict[str, torch.Tensor]][source]#

Return loss on energy and force.

Parameters:
input_dictdict[str, torch.Tensor]

Model inputs.

modeltorch.nn.Module

Model to be used to output the predictions.

labeldict[str, torch.Tensor]

Labels.

natomsint

The local atom number.

Returns:
model_pred: dict[str, torch.Tensor]

Model predictions.

loss: torch.Tensor

Loss for model to minimize.

more_loss: dict[str, torch.Tensor]

Other losses for display.

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

Add hessian label requirement needed for this loss calculation.