Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use .4g as format gives better float representation for numbers in tr… #679

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
74 changes: 37 additions & 37 deletions mace/tools/tables_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ def create_error_table(
table.add_row(
[
name,
f"{metrics['rmse_e'] * 1000:8.1f}",
f"{metrics['rmse_f'] * 1000:8.1f}",
f"{metrics['rel_rmse_f']:8.2f}",
f"{metrics['rmse_e'] * 1000:.4g}",
f"{metrics['rmse_f'] * 1000:.4g}",
f"{metrics['rel_rmse_f']:.4g}",
]
)
elif table_type == "PerAtomRMSE":
table.add_row(
[
name,
f"{metrics['rmse_e_per_atom'] * 1000:8.1f}",
f"{metrics['rmse_f'] * 1000:8.1f}",
f"{metrics['rel_rmse_f']:8.2f}",
f"{metrics['rmse_e_per_atom'] * 1000:.4g}",
f"{metrics['rmse_f'] * 1000:.4g}",
f"{metrics['rel_rmse_f']:.4g}",
]
)
elif (
Expand All @@ -148,10 +148,10 @@ def create_error_table(
table.add_row(
[
name,
f"{metrics['rmse_e_per_atom'] * 1000:8.1f}",
f"{metrics['rmse_f'] * 1000:8.1f}",
f"{metrics['rel_rmse_f']:8.2f}",
f"{metrics['rmse_stress'] * 1000:8.1f}",
f"{metrics['rmse_e_per_atom'] * 1000:.4g}",
f"{metrics['rmse_f'] * 1000:.4g}",
f"{metrics['rel_rmse_f']:.4g}",
f"{metrics['rmse_stress'] * 1000:.4g}",
]
)
elif (
Expand All @@ -161,10 +161,10 @@ def create_error_table(
table.add_row(
[
name,
f"{metrics['rmse_e_per_atom'] * 1000:8.1f}",
f"{metrics['rmse_f'] * 1000:8.1f}",
f"{metrics['rel_rmse_f']:8.2f}",
f"{metrics['rmse_virials'] * 1000:8.1f}",
f"{metrics['rmse_e_per_atom'] * 1000:.4g}",
f"{metrics['rmse_f'] * 1000:.4g}",
f"{metrics['rel_rmse_f']:.4g}",
f"{metrics['rmse_virials'] * 1000:.4g}",
]
)
elif (
Expand All @@ -174,10 +174,10 @@ def create_error_table(
table.add_row(
[
name,
f"{metrics['mae_e_per_atom'] * 1000:8.1f}",
f"{metrics['mae_f'] * 1000:8.1f}",
f"{metrics['rel_mae_f']:8.2f}",
f"{metrics['mae_stress'] * 1000:8.1f}",
f"{metrics['mae_e_per_atom'] * 1000:.4g}",
f"{metrics['mae_f'] * 1000:.4g}",
f"{metrics['rel_mae_f']:.4g}",
f"{metrics['mae_stress'] * 1000:.4g}",
]
)
elif (
Expand All @@ -187,55 +187,55 @@ def create_error_table(
table.add_row(
[
name,
f"{metrics['mae_e_per_atom'] * 1000:8.1f}",
f"{metrics['mae_f'] * 1000:8.1f}",
f"{metrics['rel_mae_f']:8.2f}",
f"{metrics['mae_virials'] * 1000:8.1f}",
f"{metrics['mae_e_per_atom'] * 1000:.4g}",
f"{metrics['mae_f'] * 1000:.4g}",
f"{metrics['rel_mae_f']:.4g}",
f"{metrics['mae_virials'] * 1000:.4g}",
]
)
elif table_type == "TotalMAE":
table.add_row(
[
name,
f"{metrics['mae_e'] * 1000:8.1f}",
f"{metrics['mae_f'] * 1000:8.1f}",
f"{metrics['rel_mae_f']:8.2f}",
f"{metrics['mae_e'] * 1000:.4g}",
f"{metrics['mae_f'] * 1000:.4g}",
f"{metrics['rel_mae_f']:.4g}",
]
)
elif table_type == "PerAtomMAE":
table.add_row(
[
name,
f"{metrics['mae_e_per_atom'] * 1000:8.1f}",
f"{metrics['mae_f'] * 1000:8.1f}",
f"{metrics['rel_mae_f']:8.2f}",
f"{metrics['mae_e_per_atom'] * 1000:.4g}",
f"{metrics['mae_f'] * 1000:.4g}",
f"{metrics['rel_mae_f']:.4g}",
]
)
elif table_type == "DipoleRMSE":
table.add_row(
[
name,
f"{metrics['rmse_mu_per_atom'] * 1000:8.2f}",
f"{metrics['rel_rmse_mu']:8.1f}",
f"{metrics['rmse_mu_per_atom'] * 1000:.4g}",
f"{metrics['rel_rmse_mu']:.4g}",
]
)
elif table_type == "DipoleMAE":
table.add_row(
[
name,
f"{metrics['mae_mu_per_atom'] * 1000:8.2f}",
f"{metrics['rel_mae_mu']:8.1f}",
f"{metrics['mae_mu_per_atom'] * 1000:.4g}",
f"{metrics['rel_mae_mu']:.4g}",
]
)
elif table_type == "EnergyDipoleRMSE":
table.add_row(
[
name,
f"{metrics['rmse_e_per_atom'] * 1000:8.1f}",
f"{metrics['rmse_f'] * 1000:8.1f}",
f"{metrics['rel_rmse_f']:8.1f}",
f"{metrics['rmse_mu_per_atom'] * 1000:8.1f}",
f"{metrics['rel_rmse_mu']:8.1f}",
f"{metrics['rmse_e_per_atom'] * 1000:.4g}",
f"{metrics['rmse_f'] * 1000:.4g}",
f"{metrics['rel_rmse_f']:.4g}",
f"{metrics['rmse_mu_per_atom'] * 1000:.4g}",
f"{metrics['rel_rmse_mu']:.4g}",
]
)
return table
20 changes: 10 additions & 10 deletions mace/tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def valid_err_log(
error_e = eval_metrics["rmse_e_per_atom"] * 1e3
error_f = eval_metrics["rmse_f"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_E_per_atom={error_e:8.2f} meV, RMSE_F={error_f:8.2f} meV / A"
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_E_per_atom={error_e:.4g} meV, RMSE_F={error_f:.4g} meV / A"
)
elif (
log_errors == "PerAtomRMSEstressvirials"
Expand All @@ -70,7 +70,7 @@ def valid_err_log(
error_f = eval_metrics["rmse_f"] * 1e3
error_stress = eval_metrics["rmse_stress"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_E_per_atom={error_e:8.2f} meV, RMSE_F={error_f:8.2f} meV / A, RMSE_stress={error_stress:8.2f} meV / A^3",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_E_per_atom={error_e:.4g} meV, RMSE_F={error_f:.4g} meV / A, RMSE_stress={error_stress:.4g} meV / A^3",
)
elif (
log_errors == "PerAtomRMSEstressvirials"
Expand All @@ -80,7 +80,7 @@ def valid_err_log(
error_f = eval_metrics["rmse_f"] * 1e3
error_virials = eval_metrics["rmse_virials_per_atom"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_E_per_atom={error_e:8.2f} meV, RMSE_F={error_f:8.2f} meV / A, RMSE_virials_per_atom={error_virials:8.2f} meV",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_E_per_atom={error_e:.4g} meV, RMSE_F={error_f:.4g} meV / A, RMSE_virials_per_atom={error_virials:.4g} meV",
)
elif (
log_errors == "PerAtomMAEstressvirials"
Expand All @@ -90,7 +90,7 @@ def valid_err_log(
error_f = eval_metrics["mae_f"] * 1e3
error_stress = eval_metrics["mae_stress"] * 1e3
logging.info(
f"{inintial_phrase}: loss={valid_loss:8.8f}, MAE_E_per_atom={error_e:8.2f} meV, MAE_F={error_f:8.2f} meV / A, MAE_stress={error_stress:8.2f} meV / A^3"
f"{inintial_phrase}: loss={valid_loss:.4g}, MAE_E_per_atom={error_e:.4g} meV, MAE_F={error_f:.4g} meV / A, MAE_stress={error_stress:.4g} meV / A^3"
)
elif (
log_errors == "PerAtomMAEstressvirials"
Expand All @@ -100,37 +100,37 @@ def valid_err_log(
error_f = eval_metrics["mae_f"] * 1e3
error_virials = eval_metrics["mae_virials"] * 1e3
logging.info(
f"{inintial_phrase}: loss={valid_loss:8.8f}, MAE_E_per_atom={error_e:8.2f} meV, MAE_F={error_f:8.2f} meV / A, MAE_virials={error_virials:8.2f} meV"
f"{inintial_phrase}: loss={valid_loss:.4g}, MAE_E_per_atom={error_e:.4g} meV, MAE_F={error_f:.4g} meV / A, MAE_virials={error_virials:.4g} meV"
)
elif log_errors == "TotalRMSE":
error_e = eval_metrics["rmse_e"] * 1e3
error_f = eval_metrics["rmse_f"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_E={error_e:8.2f} meV, RMSE_F={error_f:8.2f} meV / A",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_E={error_e:.4g} meV, RMSE_F={error_f:.4g} meV / A",
)
elif log_errors == "PerAtomMAE":
error_e = eval_metrics["mae_e_per_atom"] * 1e3
error_f = eval_metrics["mae_f"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, MAE_E_per_atom={error_e:8.2f} meV, MAE_F={error_f:8.2f} meV / A",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, MAE_E_per_atom={error_e:.4g} meV, MAE_F={error_f:.4g} meV / A",
)
elif log_errors == "TotalMAE":
error_e = eval_metrics["mae_e"] * 1e3
error_f = eval_metrics["mae_f"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, MAE_E={error_e:8.2f} meV, MAE_F={error_f:8.2f} meV / A",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, MAE_E={error_e:.4g} meV, MAE_F={error_f:.4g} meV / A",
)
elif log_errors == "DipoleRMSE":
error_mu = eval_metrics["rmse_mu_per_atom"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_MU_per_atom={error_mu:8.2f} mDebye",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_MU_per_atom={error_mu:.4g} mDebye",
)
elif log_errors == "EnergyDipoleRMSE":
error_e = eval_metrics["rmse_e_per_atom"] * 1e3
error_f = eval_metrics["rmse_f"] * 1e3
error_mu = eval_metrics["rmse_mu_per_atom"] * 1e3
logging.info(
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:8.8f}, RMSE_E_per_atom={error_e:8.2f} meV, RMSE_F={error_f:8.2f} meV / A, RMSE_Mu_per_atom={error_mu:8.2f} mDebye",
f"{inintial_phrase}: head: {valid_loader_name}, loss={valid_loss:.4g}, RMSE_E_per_atom={error_e:.4g} meV, RMSE_F={error_f:.4g} meV / A, RMSE_Mu_per_atom={error_mu:.4g} mDebye",
)


Expand Down
Loading