Skip to content

Commit 40a94fa

Browse files
authored
tiny update (#216)
* tiny update * Update pyproject.toml
1 parent fb2a97c commit 40a94fa

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "yucca"
3-
version = "2.2.10"
3+
version = "2.3.0"
44
authors = [
55
{ name="Sebastian Llambias", email="llambias@live.com" },
66
{ name="Asbjørn Munk", email="9844416+asbjrnmunk@users.noreply.github.com" },

yucca/modules/callbacks/loggers.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(
3737
self.previous_epoch = 0
3838
self.hparams: Dict[str, Any] = {}
3939
self.NAME_HPARAMS_FILE = "hparams.yaml"
40+
self.keys_logged_this_epoch = []
4041

4142
if self.disable_logging is False:
4243
if self.log_file is None:
@@ -103,6 +104,7 @@ def log_metrics(self, metrics, step):
103104
with open(self.log_file, "a+") as f:
104105
current_epoch = (step + 1) // self.steps_per_epoch
105106
if current_epoch != self.previous_epoch:
107+
self.keys_logged_this_epoch = ["epoch"]
106108
epoch_end_time = time()
107109
f.write("\n")
108110
f.write("\n")
@@ -114,10 +116,13 @@ def log_metrics(self, metrics, step):
114116
self.previous_epoch = current_epoch
115117
self.epoch_start_time = epoch_end_time
116118
for key in metrics:
117-
if key == "epoch":
119+
if key in self.keys_logged_this_epoch:
118120
continue
119-
f.write(f"{t} {key+':':20} {metrics[key]} \n")
120-
print(f"{t} {key+':':20} {metrics[key]}")
121+
else:
122+
f.write(f"{t} {key+':':20} {metrics[key]} \n")
123+
print(f"{t} {key+':':20} {metrics[key]}")
124+
self.keys_logged_this_epoch.append(key)
125+
121126
sys.stdout.flush()
122127

123128
@rank_zero_only

0 commit comments

Comments
 (0)