首页 > 其他 > 详细

H5py文件

时间:2019-01-20 15:38:37      阅读:189      评论:0      收藏:0      [点我收藏+]

h5py---字符串存储

技术分享图片
import h5py
import numpy as np
h = h5py.File(capsule_box.h5, w)
#print(h[‘user1img1‘][:])
dt = h5py.special_dtype(vlen=str)
with open(train-2000-capsul) as f:
    for lin in f:
        lines = lin.split()
        convert = lines[3:]
        a = np.array(convert)
        print(a)
        ds = h.create_dataset(user+str(lines[0])+img+str(lines[1]), a.shape, dtype=dt)
        ds[:] = a
h.close()
View Code

4.用h5py存储文件(数字字符)--example

技术分享图片
import h5py
import numpy as np
f = h5py.File(C:\\Users\\My\\Desktop\\h5\\data_box.h5, w)
 
with open(H:\\datasets_object\\box-encode-allData.trainingPair) as fr:
    for lin in fr:
        lines = lin.split()
        convert = lines[3:]
        converts =  .join(convert)
        x = np.fromstring(converts, dtype=np.uint8).astype(float64)
        # 写进h5
        name = user+lines[0]+img+lines[1]
        print(name)
        f.create_dataset(name, data=x)
f.close()
View Code

 

H5py文件

原文:https://www.cnblogs.com/dolphin-bamboo/p/10294880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!