Skip to content
Snippets Groups Projects
Commit a9df72c2 authored by Silas Dohm's avatar Silas Dohm
Browse files

tried to fix hdf5

parent 503615c3
Branches
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment