From e4e7cb1fb42a81bea63e47f64be2353de9840b69 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sun, 24 Sep 2023 19:29:57 -0400 Subject: [PATCH] fix fintune RMSE and memory issue 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 --- deepmd/fit/ener.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/deepmd/fit/ener.py b/deepmd/fit/ener.py index 9bfbf5a5cc..8ee375a84e 100644 --- a/deepmd/fit/ener.py +++ b/deepmd/fit/ener.py @@ -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."