gen_from_data() seems to assume that all the HDF5 files in the given directory path have the same number of samples.