Im using the following code to combine all hdf5 file generated by keras.
import h5py
output_file = h5py.File('output.h5', 'w')
#keep track of the total number of rows
total_rows = 0
import os
file_list = os.listdir(os.getcwd())
for n, f in enumerate(file_list):
your_data = h5py.File(n, 'r+')
total_rows = total_rows + your_data.shape[0]
total_columns = your_data.shape[1]
if n == 0:
#first file; create the dummy dataset with no max shape
create_dataset = output_file.create_dataset("Name", (total_rows, total_columns), maxshape=(None, None))
#fill the first section of the dataset
create_dataset[:,:] = your_data
where_to_start_appending = total_rows
else:
#resize the dataset to accomodate the new data
create_dataset.resize(total_rows, axis=0)
create_dataset[where_to_start_appending:total_rows, :] = your_data
where_to_start_appending = total_rows
output_file.close()
it is throwing the following error.
expected str bytes or osPathLike objects.
why so? how can I be able to combine all hdf5 data sets from keras?