Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word2vec.doesnt_match numpy vstack deprecation warning #2988

Closed
atunanggara opened this issue Oct 22, 2020 · 1 comment
Closed

word2vec.doesnt_match numpy vstack deprecation warning #2988

atunanggara opened this issue Oct 22, 2020 · 1 comment

Comments

@atunanggara
Copy link

Problem description

I followed this instruction to load GloVe model. When I run: model.doesnt_match("breakfast cereal dinner lunch".split()) from the tutorial, it produces FutureWarning on the vstack function. It seems that I am not the first person to encounter this error as well. It might also be similar to Issue 2432. The error reads:

C:\Path_to_gensim\keyedvectors.py:877: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
vectors = vstack(self.word_vec(word, use_norm=True) for word in used_words).astype(REAL)

Steps/code/corpus to reproduce

from gensim.test.utils import datapath, get_tmpfile  
from gensim.models import KeyedVectors  
from gensim.scripts.glove2word2vec import glove2word2vec  

glove_file = datapath('test_glove.txt')  
tmp_file = get_tmpfile("test_word2vec.txt")  
_ = glove2word2vec(glove_file, tmp_file)  
model = KeyedVectors.load_word2vec_format(tmp_file)  
model.doesnt_match("breakfast cereal dinner lunch".split())

Versions

Windows-10-10.0.17763-SP0   
python 3.8.2   (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]   
Bits 64   
NumPy 1.19.0   
SciPy 1.5.2   
gensim 3.8.3   
FAST_VERSION 0
@gojomo
Copy link
Collaborator

gojomo commented Oct 23, 2020

In general, you don't have to worry about such DeprecationWarning messages - they don't affect functionality, and will be fixed when the functionality breaks.

But, in this case the code has already been fixed to avoid passing a generator to vstackbefore, after – so the warning against this usage won't appear when using the next gensim release (4.0.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants