Skip to content

Commit

Permalink
Log dataset sizes (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostedoyster authored Jun 11, 2024
1 parent 75b4167 commit b99b331
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/metatrain/cli/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,31 @@ def train_model(
)
validation_datasets.append(validation_dataset)

###########################
# PRINT DATASET STATS #####
###########################

for i, train_dataset in enumerate(train_datasets):
if len(train_datasets) == 1:
index = ""
else:
index = f" {i}"
logger.info(f"Training dataset{index} has size {len(train_dataset)}")

for i, validation_dataset in enumerate(validation_datasets):
if len(validation_datasets) == 1:
index = ""
else:
index = f" {i}"
logger.info(f"Validation dataset{index} has size {len(validation_dataset)}")

for i, test_dataset in enumerate(test_datasets):
if len(test_datasets) == 1:
index = ""
else:
index = f" {i}"
logger.info(f"Test dataset{index} has size {len(test_dataset)}")

###########################
# SAVE EXPANDED OPTIONS ###
###########################
Expand Down
3 changes: 3 additions & 0 deletions tests/cli/test_train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def test_train(capfd, monkeypatch, tmp_path, output):
for logtext in [stdout_log, file_log]:
assert "This log is also available"
assert re.search(r"Random seed of this run is [1-9]\d*", logtext)
assert "Training dataset has size"
assert "Validation dataset has size"
assert "Test dataset has size"
assert "[INFO]" in logtext
assert "Epoch" in logtext
assert "loss" in logtext
Expand Down

0 comments on commit b99b331

Please sign in to comment.