测试读取npy文件和hdf5文件的速度优劣
import time import h5py import numpy as np s = time.time() img_path = r'D:\DataDemo' out_h5_path = r'D:\DataDemo\test_hdf5.h5' f = h5py.File(out_h5_path, 'r') i=0 while i<1000: image_stack = f['train'][:] i +=1 e = time.time() print(e-s) s1 = time.time() j=0 while j<1000: image_array = np.load(img_path+'\\train.npy') j+=1 e1 = time.time() print(e1-s1) # 2.433586835861206 # 2.817115545272827 # 速度差不多