Slide 18
Slide 18 text
疎⾏列の保存:HDF5 Store
▶ 疎⾏列を複数のベクトルで圧縮表現
▶ ベクトルも blosc アルゴリズムで圧縮して HDF5 に保存する
# 疎⾏列 CSC Matrix を複数の数値列で圧縮表現して HDF5 に保存する
def savemat(X, filepath):
X = ss.csc_matrix(X)
with tables.open_file(filepath, 'w') as f:
filters = tables.Filters(complevel=5, complib='blosc')
out_data = f.create_earray(
f.root, 'data', tables.Float32Atom(), shape=(0,), filters=filters)
out_indices = f.create_earray(
f.root, 'indices', tables.Int32Atom(), shape=(0,), filters=filters)
out_indptr = f.create_earray(
f.root, 'indptr', tables.Int32Atom(), shape=(0,), filters=filters)
out_shape = f.create_earray(
f.root, 'shape', tables.Int32Atom(), shape=(0,), filters=filters)
out_data.append(X.data)
out_indices.append(X.indices)
out_indptr.append(X.indptr)
out_shape.append(np.array([X.shape[0], X.shape[1]]))