Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gensim import utils
- def save2gensim(fname, word2vec_dict):
- vectors = list(word2vec_dict.values())
- vector_size = vectors[0].shape[0]
- total_vec = len(vectors)
- with utils.smart_open(fname, 'wb') as fout:
- fout.write(utils.to_utf8("%s %s\n" % (total_vec, vector_size)))
- # store in sorted order: most frequent words at the top
- for word, vector in word2vec_dict.items():
- fout.write(utils.to_utf8("%s %s\n" % (word, ' '.join(repr(val) for val in vector))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement