Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 3de145c

Browse files
committed
Switch output writing to h5py to reduce memory footprint. Update version
1 parent 2075548 commit 3de145c

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.659
1+
1.1.2

rinokeras/core/v1x/train/RinokerasGraph.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Sequence, Union, Any, Optional, Dict
33
import pickle as pkl
44

5+
import h5py
56
import tensorflow as tf
67
from tensorflow.python.client import timeline
78
from tqdm import tqdm
@@ -160,21 +161,22 @@ def run_epoch(self,
160161
epoch_num: Optional[int] = None,
161162
summary_writer: Optional[tf.summary.FileWriter] = None,
162163
save_outputs: Optional[str] = None) -> MetricsAccumulator:
163-
all_outputs = []
164164

165165
with self.add_progress_bar(data_len, epoch_num).initialize():
166166
assert self.epoch_metrics is not None
167-
while True:
168-
if save_outputs is not None:
169-
loss, outputs = self.run('default', return_outputs=True)
170-
all_outputs.append(outputs)
171-
else:
167+
if save_outputs is not None:
168+
i = 0
169+
with h5py.File(save_outputs, 'w') as f:
170+
while True:
171+
loss, outputs = self.run('default', return_outputs=True)
172+
grp = f.create_group(str(i))
173+
outputs = outputs[0] # can we rely on this being a tuple of length 1?
174+
for key in outputs.keys():
175+
grp.create_dataset(key, data=outputs[key])
176+
i += 1
177+
else:
178+
while True:
172179
self.run('default')
173-
174-
if save_outputs is not None:
175-
with open(save_outputs, 'wb') as f:
176-
pkl.dump(all_outputs, f)
177-
178180
return self.epoch_metrics
179181

180182
def run_for_n_steps(self,

0 commit comments

Comments
 (0)