benchmark.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:tfutils 作者: neuroailab 项目源码 文件源码
def create_hdf5(n_img, path=None, shape=(IMSIZE, IMSIZE, 3), im_dtype=np.float32):
    if path is None:
        path = '/tmp'
    # os.makedirs(path)
    tempf = tempfile.NamedTemporaryFile(suffix='.hdf5', dir=path, delete=False)
    tempf.close()
    with h5py.File(tempf.name, 'w') as f:
        f.create_dataset('data', ((n_img, ) + shape), dtype=im_dtype)
        f.create_dataset('labels', (n_img, ), dtype=np.int64)
        img = np.random.randn(*shape)
        label = np.random.randint(1000)
        for i in tqdm.trange(n_img, desc='creating hdf5 file'):
            f['data'][i] = img
            f['labels'][i] = label
    return tempf.name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号