Skip to content

Commit 67f30e0

Browse files
njzjzwanghan-iapcmpre-commit-ci[bot]
authored
fix finetune RMSE and memory issue (#2860)
Fix #2472. The previous implementation tried to allocate a (N, N) array and the RMSE result was actually MAE instead. --------- Signed-off-by: Jinzhe Zeng <[email protected]> Signed-off-by: Han Wang <[email protected]> Co-authored-by: Han Wang <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ffe10f9 commit 67f30e0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

deepmd/fit/ener.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,13 @@ def change_energy_bias(
856856
delta_bias = np.linalg.lstsq(type_numbs, bias_diff, rcond=None)[0]
857857
unbias_e = energy_predict + type_numbs @ delta_bias
858858
atom_numbs = type_numbs.sum(-1)
859-
rmse_ae = (
860-
np.sqrt(np.square(unbias_e - energy_ground_truth)) / atom_numbs
861-
).mean()
859+
rmse_ae = np.sqrt(
860+
np.mean(
861+
np.square(
862+
(unbias_e.ravel() - energy_ground_truth.ravel()) / atom_numbs
863+
)
864+
)
865+
)
862866
self.bias_atom_e[idx_type_map] += delta_bias.reshape(-1)
863867
log.info(
864868
f"RMSE of atomic energy after linear regression is: {rmse_ae} eV/atom."

0 commit comments

Comments
 (0)