deepmd.pd.loss#

Submodules#

Classes#

EnergyHessianStdLoss

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

EnergyStdLoss

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

TaskLoss

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

Package Contents#

class deepmd.pd.loss.EnergyHessianStdLoss(start_pref_h=0.0, limit_pref_h=0.0, **kwargs)[source]#

Bases: EnergyStdLoss

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

has_h#
start_pref_h = 0.0#
limit_pref_h = 0.0#
forward(input_dict, model, label, natoms, learning_rate, mae=False)[source]#

Return loss on energy and force.

Parameters:
input_dictdict[str, paddle.Tensor]

Model inputs.

modelpaddle.nn.Layer

Model to be used to output the predictions.

labeldict[str, paddle.Tensor]

Labels.

natomsint

The local atom number.

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

Model predictions.

loss: paddle.Tensor

Loss for model to minimize.

more_loss: dict[str, paddle.Tensor]

Other losses for display.

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

Add hessian label requirement needed for this loss calculation.

class deepmd.pd.loss.EnergyStdLoss(starter_learning_rate=1.0, start_pref_e=0.0, limit_pref_e=0.0, start_pref_f=0.0, limit_pref_f=0.0, start_pref_v=0.0, limit_pref_v=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, use_l1_all: bool = False, inference=False, use_huber=False, huber_delta=0.01, **kwargs)[source]#

Bases: deepmd.pd.loss.loss.TaskLoss

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

starter_learning_rate = 1.0#
has_e#
has_f#
has_v#
has_ae#
has_pf#
has_gf#
start_pref_e = 0.0#
limit_pref_e = 0.0#
start_pref_f = 0.0#
limit_pref_f = 0.0#
start_pref_v = 0.0#
limit_pref_v = 0.0#
start_pref_ae = 0.0#
limit_pref_ae = 0.0#
start_pref_pf = 0.0#
limit_pref_pf = 0.0#
start_pref_gf = 0.0#
limit_pref_gf = 0.0#
relative_f = None#
enable_atom_ener_coeff = False#
numb_generalized_coord = 0#
use_l1_all = False#
inference = False#
use_huber = False#
huber_delta = 0.01#
forward(input_dict, model, label, natoms, learning_rate, mae=False)[source]#

Return loss on energy and force.

Parameters:
input_dictdict[str, paddle.Tensor]

Model inputs.

modelpaddle.nn.Layer

Model to be used to output the predictions.

labeldict[str, paddle.Tensor]

Labels.

natomsint

The local atom number.

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

Model predictions.

loss: paddle.Tensor

Loss for model to minimize.

more_loss: dict[str, paddle.Tensor]

Other losses for display.

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

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.pd.loss.loss.TaskLoss[source]#

Deserialize the loss module.

Parameters:
datadict

The serialized loss module

Returns:
Loss

The deserialized loss module

class deepmd.pd.loss.TaskLoss(**kwargs)[source]#

Bases: paddle.nn.Layer, abc.ABC, make_plugin_registry('loss')

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

abstractmethod forward(input_dict, model, label, natoms, learning_rate)[source]#

Return loss .

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

Return data label requirements needed for this loss calculation.

static display_if_exist(loss: paddle.Tensor, find_property: float) paddle.Tensor[source]#

Display NaN if labeled property is not found.

Parameters:
losspaddle.Tensor

the loss tensor

find_propertyfloat

whether the property is found

classmethod get_loss(loss_params: dict) TaskLoss[source]#

Get the loss module by the parameters.

By default, all the parameters are directly passed to the constructor. If not, override this method.

Parameters:
loss_paramsdict

The loss parameters

Returns:
TaskLoss

The loss module