I’m trying to do this Word2Vec code and getting a NameError: name ‘gensim’ is not defined:
w2v_model = gensim.models.Word2Vec(docgen, min_count=5, sg=1, seed=22122, workers=1)
When I went to import gensim, I got this error: ImportError: cannot import name ‘triu’ from ‘scipy.linalg’ (/opt/conda/lib/python3.9/site-packages/scipy/linalg/init.py)
How would I fix the code to be able to call Gensim? I need Word2Vec to run and haven’t had this problem before; I was running this model this morning and it was fine, but now suddenly it’s giving an error.
I saw that you’d have to upgrade Scipy, and it seemed to work. This is the full code:
!pip install scipy==1.10.1
!pip install gensim
from numpy import triu
import gensim
from gensim import corpora, models
w2v_model = gensim.models.Word2Vec(docgen, min_count=3, sg=1, seed=22122, workers=1)
Thanks!
mp223123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.