hdf5 的使用

版权声明:本文为博主原创文章,欢迎转载,转载请注明出处。 https://blog.csdn.net/cjh_jinduoxia/article/details/88338386

python 上的使用

import h5py

保存hdf5文件

# Write numpy array data and label to h5_filename
def save_h5(h5_filename, data, label, data_dtype='uint8', label_dtype='uint8'):
	'''
	svae_h5 用于创建并存储h5文件
	'''
    h5_fout = h5py.File(h5_filename)
    h5_fout.create_dataset(
            'data', data=data,
            compression='gzip', compression_opts=4,
            dtype=data_dtype)
    h5_fout.create_dataset(
            'label', data=label,
            compression='gzip', compression_opts=1,
            dtype=label_dtype)
    h5_fout.close()

读取hdf5文件

# Read numpy array data and label from h5_filename
def load_h5(h5_filename):
	'''
	load_h5 用来加载 h5 文件
	'''
    f = h5py.File(h5_filename)
    data = f['data'][:]
    label = f['label'][:]
    return (data, label)

c++ 上的使用

猜你喜欢

转载自blog.csdn.net/cjh_jinduoxia/article/details/88338386
今日推荐