Created
March 18, 2018 13:54
-
-
Save psinger/c6615508340583b20b81c9f90e48480a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
f = tb.open_file('dot.h5', 'w') | |
filters = tb.Filters(complevel=5, complib='blosc') | |
out_data = f.create_earray(f.root, 'data', tb.Float32Atom(), shape=(0,), filters=filters) | |
out_indices = f.create_earray(f.root, 'indices', tb.Int32Atom(),shape=(0,), filters=filters) | |
out_indptr = f.create_earray(f.root, 'indptr', tb.Int32Atom(), shape=(0,), filters=filters) | |
out_indptr.append(np.array([0])) #this is needed as a first indptr | |
max_indptr = 0 | |
for i in range(0, l, bl): | |
res = a[i:min(i+bl, l),:].dot(b) | |
out_data.append(res.data) | |
indices = res.indices | |
indptr = res.indptr | |
out_indices.append(indices) | |
out_indptr.append(max_indptr+indptr[1:]) | |
max_indptr += indices.shape[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment