deepmd.pt_expt.loss.tensor#

Classes#

TensorLoss

Loss on local and global tensors (e.g. dipole, polarizability).

Module Contents#

class deepmd.pt_expt.loss.tensor.TensorLoss(tensor_name: str, tensor_size: int, label_name: str, pref_atomic: float = 0.0, pref: float = 0.0, enable_atomic_weight: bool = False, **kwargs: Any)[source]#

Bases: deepmd.dpmodel.loss.loss.Loss

Loss on local and global tensors (e.g. dipole, polarizability).

Parameters:
tensor_namestr

The name of the tensor in model predictions.

tensor_sizeint

The size (dimension) of the tensor.

label_namestr

The name of the tensor in labels.

pref_atomicfloat

The prefactor of the weight of atomic (local) loss.

preffloat

The prefactor of the weight of global loss.

enable_atomic_weightbool

If true, atomic weight will be used in the loss calculation.

**kwargs

Other keyword arguments.

tensor_name#
tensor_size#
label_name#
local_weight = 0.0#
global_weight = 0.0#
enable_atomic_weight = False#
has_local_weight#
has_global_weight#
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]#

Return data label requirements needed for this loss calculation.

serialize() dict[source]#

Serialize the loss module.

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

Deserialize the loss module.