Created
April 17, 2020 00:43
-
-
Save duhaime/0f7c3bcb58b5b8b70ccd18f7e90429d7 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 | |
import sys | |
import struct | |
dim = 50 | |
a = np.load('stacked-vecs-{}.npy'.format(dim)) | |
with open('stacked.fvecs', 'wb') as out: | |
for i in a: | |
line = [float(j) for j in i] | |
out.write(struct.pack('=I', dim)) | |
out.write(struct.pack('={}{}'.format(dim, 'f'), *line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment