Model Saving in Gensim Word2Vec

1,479 views
Skip to first unread message

SUBHABRATA BANERJEE

unread,
May 30, 2015, 8:07:45 AM5/30/15
to gen...@googlegroups.com
Dear Group,

To save the result of Word2Vec there is a tutorial, https://radimrehurek.com/gensim/models/word2vec.html
but if I use pickle, as I am doing

>>> from gensim.models import Word2Vec
>>> from nltk.corpus import brown, movie_reviews, treebank
>>> b = Word2Vec(brown.sents())
>>> import pickle
>>> f = open('my_classifier5.pickle', 'wb')
>>> pickle.dump(b, f)
>>> f.close()
>>> f 1= open('my_classifier5.pickle')
>>> classifier=pickle.load(f1)
>>> classifier.most_similar('money', topn=5)
[('pay', 0.6861867904663086), ('ready', 0.6255729794502258), ('try', 0.6118115186691284), ('go', 0.609034538269043), ('oppose', 0.6002943515777588)]
>>> f1.close()
is giving me nice result.
Am I going fine?

Regards,
Subhabrata Banerjee.









Christopher S. Corley

unread,
May 30, 2015, 11:05:22 PM5/30/15
to gensim
Ha, if this works for you, then great :)

I wouldn't expect any model functionality, such as adding new documents in an online manner, to work, though. Why not use the built in save/load?

Chris.

--
You received this message because you are subscribed to the Google Groups "gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

SUBHABRATA BANERJEE

unread,
Jun 1, 2015, 3:02:21 AM6/1/15
to gen...@googlegroups.com
Dear Sir,

Thanks for your kind comment. I tried built-in save/load also giving same result. So now got two choices.

Regards,
Subhabrata Banerjee.
Reply all
Reply to author
Forward
0 new messages