From 2e0498277d6d4c2f4297fe8b957e0276f5ea3f16 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Wed, 1 May 2019 13:00:37 +0200 Subject: [PATCH] Only new lists should be saved Signed-off-by: Jim Martens --- src/twomartens/masterthesis/ssd.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/twomartens/masterthesis/ssd.py b/src/twomartens/masterthesis/ssd.py index 61afcee..8454eb2 100644 --- a/src/twomartens/masterthesis/ssd.py +++ b/src/twomartens/masterthesis/ssd.py @@ -182,6 +182,7 @@ def _predict_one_epoch(dataset: tf.data.Dataset, counter = 0 import gc from tensorflow.python.eager import context + lists = None for inputs in dataset: decoded_predictions_batch = [] @@ -216,9 +217,14 @@ def _predict_one_epoch(dataset: tf.data.Dataset, from pympler import muppy, summary all_objects = muppy.get_objects() all_lists = muppy.filter(all_objects, Type=list) - for i, l in enumerate(all_lists): - with open(f"list-{i}.txt", "w") as file: - file.write(str(l)) + if lists is None: + lists = map(id, all_lists) + list_nr = 0 + for l in all_lists: + if id(l) not in lists: + with open(f"list-{counter}-{list_nr}.txt", "w") as file: + file.write(l) + list_nr += 1 epoch_end_time = time.time() per_epoch_time = epoch_end_time - epoch_start_time