栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用HDF5的矩阵乘法

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用HDF5的矩阵乘法

我不知道在不加载到内存的情况下工作的np.dot。我认为屏蔽会很好。创建一个输出数组(以下称为“ c”)作为pytables
CArray并填写块。创建块形状以匹配其阻止方案时,应选择块形状。就像是

atom = tables.Float32Atom() # you have UInt8Atom() above.  do you mean that?shape = (a.shape[0], b.shape[1])# you can vary block_size and chunkshape independently, but I would# aim to have block_size an integer multiple of chunkshape# your mileage may vary and depends on the array size and how you'll# access it in the future.Nchunk = 128  # ?chunkshape = (Nchunk, Nchunk)chunk_multiple = 1block_size = chunk_multiple * Nchunkc = h5f.create_carray(h5.root, 'c', atom, shape, chunkshape=chunkshape)for i_start in range(0, a.shape[0], block_size):    for j_start in range(0, b.shape[1], block_size):        for k_start in range(0, a.shape[1], block_size): c[i_start:i_start+block_size, j_start:j_start + block_size] +=           np.dot(a[i_start:i_start + block_size, k_start:k_start + block_size],     b[k_start:k_start + block_size, j_start:j_start + block_size]


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/596536.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号