• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    Python
  • Created almost 9 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

word2vec uisng keras inside gensim

word2vec-keras-in-gensim

Just rewrite train function in gensim.models.word2vec.Word2Vec and gensim.models.doc2vec.Doc2Vec using Keras+Theano

like

class Word2VecKeras(gensim.models.word2vec.Word2Vec):
     def train(...

And can use GPU via Theano.

Install

pip install word2veckeras

Usage

same to gensim.models.word2vec.Word2Vec

Example

vsk = Word2VecKeras(gensim.models.word2vec.LineSentence('test.txt'),iter=100)
print( vsk.most_similar('the', topn=5))

from nltk.corpus import brown
brk = Word2VecKeras(brown.sents(),iter=10)
print( brk.most_similar('the', topn=5))

Requirements

pip install -U keras