Skip to content

Commit

Permalink
fix finetune RMSE result (#123)
Browse files Browse the repository at this point in the history
* fix finetune RMSE result

The previous RMSE result was actually MAE instead.

See also deepmodeling/deepmd-kit#2860.

* apply changes in deepmodeling/deepmd-kit#2860
  • Loading branch information
njzjz authored Oct 13, 2023
1 parent c161ba5 commit de5ebaf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions deepmd_pt/model/task/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ def change_energy_bias(self, config, model, old_type_map, new_type_map, bias_shi
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).reshape(-1)) / 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] += torch.from_numpy(delta_bias.reshape(-1)).to(DEVICE)
logging.info(
"RMSE of atomic energy after linear regression is: {:10.5e} eV/atom.".format(
Expand Down

0 comments on commit de5ebaf

Please sign in to comment.