Skip to content

Commit

Permalink
fix fintune RMSE and memory issue
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
njzjz committed Sep 24, 2023
1 parent c2c6476 commit e4e7cb1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deepmd/fit/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,12 @@ def change_energy_bias(
delta_bias = np.linalg.lstsq(type_numbs, bias_diff, rcond=None)[0]
unbias_e = energy_predict + type_numbs @ delta_bias
atom_numbs = type_numbs.sum(-1)
rmse_ae = (
np.sqrt(np.square(unbias_e - energy_ground_truth)) / atom_numbs
).mean()
rmse_ae = np.sqrt(
np.mean(
np.square(unbias_e.ravel() - energy_ground_truth.ravel())
/ atom_numbs
)
)
self.bias_atom_e[idx_type_map] += delta_bias.reshape(-1)
log.info(
f"RMSE of atomic energy after linear regression is: {rmse_ae} eV/atom."
Expand Down

0 comments on commit e4e7cb1

Please sign in to comment.