Reputation:
Code :
from gensim.models.word2vec import Word2Vec
w2v = Word2Vec()
training_data = w2v.generate_training_data(settings, corpus)
Error :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-45-bae554564046> in <module>
1 w2v = Word2Vec()
2 # Numpy ndarray with one-hot representation for [target_word, context_words]
----> 3 training_data = w2v.generate_training_data(settings, corpus)
AttributeError: 'Word2Vec' object has no attribute 'generate_training_data'
I even tried importing gensim.models.word2vec and tried every possibility but couldn't get it done. Can someone help me with it? Thanks in advance !
Upvotes: 0
Views: 950
Reputation: 54183
Yes, the gensim
Word2Vec
class doesn't have that method – and as far as I know, it never has.
And from your example usage, I'm not even sure what it might purport to do: a Word2Vec
model needs to be provided data in the right format – it doesn't "generate" it (even as a translation from some other corpus).
I suspect you are looking at docs or a code example from some other unrelated library.
For using gensim
's Word2Vec
, you should rely on the gensim
documentation & examples. The class docs include some basic details of proper usage, and there's a Jupyter notebook word2vec.ipynb
included with the library, in its docs/notebooks
directory (and also viewable online).
Upvotes: 1