Skip to content

Commit

Permalink
pt: fix print_on_training when there is no validation data
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>

#3405 changed results from `None` to `{}` but `print_on_training` wasn't revised.
  • Loading branch information
njzjz committed Mar 6, 2024
1 parent 278e6b8 commit d05e27b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deepmd/pt/train/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ def print_on_training(self, fout, step_id, cur_lr, train_results, valid_results)
print_str = ""
print_str += "%7d" % step_id
if not self.multi_task:
if valid_results is not None:
if valid_results:

Check warning on line 1019 in deepmd/pt/train/training.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/train/training.py#L1019

Added line #L1019 was not covered by tests
prop_fmt = " %11.2e %11.2e"
for k in train_keys:
print_str += prop_fmt % (valid_results[k], train_results[k])
Expand All @@ -1026,7 +1026,7 @@ def print_on_training(self, fout, step_id, cur_lr, train_results, valid_results)
print_str += prop_fmt % (train_results[k])
else:
for model_key in self.model_keys:
if valid_results[model_key] is not None:
if valid_results[model_key]:

Check warning on line 1029 in deepmd/pt/train/training.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/train/training.py#L1029

Added line #L1029 was not covered by tests
prop_fmt = " %11.2e %11.2e"
for k in sorted(valid_results[model_key].keys()):
print_str += prop_fmt % (
Expand Down

0 comments on commit d05e27b

Please sign in to comment.