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

tried to fix hdf5

parent 503615c3
No related branches found
No related tags found
No related merge requests found
...@@ -142,20 +142,19 @@ if __name__ == '__main__': ...@@ -142,20 +142,19 @@ if __name__ == '__main__':
#%% #%%
import h5py import h5py
def hdf5Generator(filePath, batch_size, dataSet): def hdf5Generator(filePath, batch_size, dataSet,loop=True):
with h5py.File(filePath, 'r') as hf: with h5py.File(filePath, 'r') as hf:
L = len(hf["X" + dataSet]) L = len(hf["X" + dataSet])
while True: while True:
batch_start = 0 batch_start = 0
batch_end = batch_size batch_end = batch_size
while batch_start < L: while batch_end < L:
limit = min(batch_end, L) X = hf["X" + dataSet][batch_start:batch_end]
X = hf["X" + dataSet][batch_start:limit] Y = hf["Y" + dataSet][batch_start:batch_end]
Y = hf["Y" + dataSet][batch_start:limit]
yield (X,Y) #a tuple with two numpy arrays with batch_size samples yield (X,Y) #a tuple with two numpy arrays with batch_size samples
batch_start += batch_size batch_start += batch_size
batch_end += 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