Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deepmd/dpmodel/loss/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def call(
natoms: int,
model_dict: dict[str, Array],
label_dict: dict[str, Array],
) -> dict[str, Array]:
) -> tuple[Array, dict[str, Array]]:
"""Calculate loss from model results and labeled results."""
energy = model_dict["energy"]
force = model_dict["force"]
Expand Down Expand Up @@ -244,10 +244,10 @@ def call(
if self.has_gf:
find_drdq = label_dict["find_drdq"]
drdq = label_dict["drdq"]
force_reshape_nframes = xp.reshape(force, (-1, natoms[0] * 3))
force_hat_reshape_nframes = xp.reshape(force_hat, (-1, natoms[0] * 3))
force_reshape_nframes = xp.reshape(force, (-1, natoms * 3))
force_hat_reshape_nframes = xp.reshape(force_hat, (-1, natoms * 3))
drdq_reshape = xp.reshape(
drdq, (-1, natoms[0] * 3, self.numb_generalized_coord)
drdq, (-1, natoms * 3, self.numb_generalized_coord)
)
gen_force_hat = xp.einsum(
"bij,bi->bj", drdq_reshape, force_hat_reshape_nframes
Expand Down
12 changes: 10 additions & 2 deletions deepmd/dpmodel/loss/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ def call(
natoms: int,
model_dict: dict[str, Array],
label_dict: dict[str, Array],
) -> dict[str, Array]:
"""Calculate loss from model results and labeled results."""
) -> tuple[Array, dict[str, Array]]:
"""Calculate loss from model results and labeled results.

Returns
-------
loss
The scalar loss to minimize.
more_loss
A dictionary of additional loss terms/metrics for logging.
"""

@property
@abstractmethod
Expand Down
Loading