码迷,mamicode.com
首页 > 其他好文 > 详细

H5py文件

时间:2019-01-20 16:02:12      阅读:465      评论:0      收藏:0      [点我收藏+]

标签:view   col   one   class   special   存储   pre   lda   nump   

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文件

标签:view   col   one   class   special   存储   pre   lda   nump   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!