I want to reshape my h5py dataset like I can do with numpy.reshape(). The following Code is only working if I use numpy.array() at the beginning of the code. But that only works with a small dataset and blows up my memory if I take a bigger one.
import h5py
import numpy as np
#load data
h5py_data_path = 'any\path\to\h5pyData\training.data.h5'
t_data = h5py.File(h5py_data_path,'r')
training_data = t_data['training.data']
######################################
#### Don't want to have this (blows up my memory) ####
training_data = np.array(training_data)
######################################
print('training_data ',training_data.shape)
#out: training_data (10203, 5, 341)
#reshape data
######################################
#### That works, but only with upper Numpy Code ####
training_data = training_data.reshape(training_data.shape[0], 1, 5, 341)
######################################
print('training_data ',training_data.shape)
#out: training_data (10203, 1, 5, 341)
Is there any native way in h5py to reshape that in any other working way?