I have trained a Word2Vec embedding using deeplearning4j.
How can I export the resulting Word2Vec
model to a vectors.tsv
and metadata.tsv
so I can visualize it using the https://projector.tensorflow.org/ ?
I have trained a Word2Vec embedding using deeplearning4j.
How can I export the resulting Word2Vec
model to a vectors.tsv
and metadata.tsv
so I can visualize it using the https://projector.tensorflow.org/ ?
try this out.
# your word2vec model loaded in `w2v_model`
with open('tensors.tsv', 'w') as tensors:
with open('metadata.tsv', 'w') as metadata:
for word in w2v_model.wv.index2word:
metadata.write(word + '\n')
vector_row = '\t'.join(map(str, w2v_model.wv[word]))
tensors.write(vector_row + '\n')