A HDF5 file is a container for two types of objects: DataSet and group. A dataset is an array-like DataSet, and group is a folder-like container that holds datasets and other group. When using h5py, you need to keep in mind a word: Groups analogy dictionary, dataset analogy numpy in the array.
Although the HDF5 dataset is similar to the NumPy array on the interface, it supports more externally transparent storage features such as data compression, error detection, and chunked transmission.
HDF5 storage model files or datasets are also commonly used in deep learning
ImportH5py#Importing the toolkitImportNumPy as NP#write to HDF5:Imgdata = Np.zeros ((30,3,128,256)) F= H5py. File ('Hdf5_file.h5','W')#Create a H5 file, the file pointer is Ff['Data'] = Imgdata#write data to the file's primary key data belowf['Labels'] = range (100)#write data to the file's primary key labels belowF.close ()#Close File #read from HDF5:f = h5py. File ('Hdf5_file.h5','R')#Open h5 fileF.keys ()#You can view all the primary keysA = f['Data'][:]#Remove all key values for the primary key dataF.close ()
Description of the "Python series" HDF5 file