Repository navigation
Write each row of the NEP training report once for both the standard output and loss.out - #1813
Merged
Merged
Conversation
Fitness::report_error writes a report row to the standard output and to loss.out through one lambda that takes a FILE*, instead of two copies of each format string and argument list per model branch.
Collaborator
Author
|
@brucefan1983 this is a refactor of the code for writing the loss row to both stdout and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fitness::report_errorinsrc/main_nep/fitness.cuwrote every row of the training report twice, once withprintfto the standard output and once withfprintftoloss.out. The NEP, charge-model and TNEP branches each held the format string and the argument list in two identical copies, and a column added to one copy had to be added to the other by hand.This PR replaces the duplicated calls with one lambda,
write_row, that takes aFILE*and is called once withstdoutand once withfid_loss_out. It holds the three model branches and writes the energy-difference columns within the branch of the potential models, which are the only models that acceptlambda_d. The format strings and the order of the columns are unchanged.Testing
No test is added, since the output is unchanged. Baseline and candidate
nepwere built from master and from this branch with-DDEBUG, and run on the same inputs with a test set and three report rows each: NEP, charge_mode 1, charge_mode 2, charge_vdw, vdw, TNEP dipole and TNEP polarizability models, the potential models with and withoutlambda_d.loss.outis byte-identical in all 10 cases, and the standard output differs only in the two lines that report the wall-clock time. An independent run of 28 cases, which adds model_type 3, runs without a test set and a restart fromnep.restart, gave the same result.pytest -m "not slow"ontests_pytest/test_ediff_loss.pyandtests_pytest/test_nep_train_outputs.py: 87 passed.git-clang-formatreports no changes. The fulltests_regressionsuite was not run.