From a9df72c2fc8b6c6ed77e86cac85451772606fe7b Mon Sep 17 00:00:00 2001 From: Silas Dohm <silas@sdohm.xyz> Date: Mon, 2 Aug 2021 01:56:19 +0200 Subject: [PATCH] tried to fix hdf5 --- python/hdf5.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python/hdf5.py b/python/hdf5.py index 4acbccf..1368101 100644 --- a/python/hdf5.py +++ b/python/hdf5.py @@ -142,20 +142,19 @@ if __name__ == '__main__': #%% import h5py -def hdf5Generator(filePath, batch_size, dataSet): +def hdf5Generator(filePath, batch_size, dataSet,loop=True): with h5py.File(filePath, 'r') as hf: L = len(hf["X" + dataSet]) while True: batch_start = 0 batch_end = batch_size - while batch_start < L: - limit = min(batch_end, L) - X = hf["X" + dataSet][batch_start:limit] - Y = hf["Y" + dataSet][batch_start:limit] - + while batch_end < L: + X = hf["X" + dataSet][batch_start:batch_end] + Y = hf["Y" + dataSet][batch_start:batch_end] yield (X,Y) #a tuple with two numpy arrays with batch_size samples batch_start += batch_size batch_end += batch_size + if not loop: break \ No newline at end of file -- GitLab