-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Doc2Vec.infer_vector: AttributeError: 'Doc2Vec' object has no attribute 'syn1' #483
Comments
I could handle the error i two ways:
I'm not a deep expert in this topic, but I think the hs (hierachical sampling for training) seems to me important isn't it? Also the |
I just figured out. it also works with
|
I think it's clear now. When I'm right, it might be good to give an appropriate error/warning, or/and add a comment in the docs. |
Thanks for your report. Yes, inference works almost exactly like training, so a model with training-state discarded won't be able to reasonably infer either. The comment for This area might benefit from a bit more renaming/commenting/refactoring for full clarity, for a few reasons related to what...
|
@gojomo Should this be marked as easy? |
m = g.Doc2Vec.load(saved_path) #load model
test_docs = [ x.strip().split() for x in codecs.open(test_docs, "r","utf-8").readlines() ]
output = open(output_file, "w")
for d in test_docs:
output.write(" ".join([str(x) for x in m.infer_vector(d, alpha=start_alpha, steps=infer_epoch)]) + "\n") when I run these code, I get the error:AttributeError: 'Doc2Vec' object has no attribute 'neg_labels' |
@StevenChen1993 - Are you receiving a "slow version" warning in logs when you use |
thanks for your answer! |
Hi I had the same exception. The problem was that the model was trained using the fast version but when I installed gensim (3.8.0) on Windows I did not get a warning that the slow version was used. I followed the instruction on https://radimrehurek.com/gensim/install.html which then successfully installed the fast version of Gensim (3.8.0) on Windows: PS: |
Thanks @felixsmueller ; cross-linking to #2600 . @mpenkov do we instruct people to use the |
@piskvorky I'm totally unfamiliar with conda myself. Do any of the gensim developers actually use it? If yes, it'd be good for that person to handle it. If no, then I suppose "one of us" could dedicate some time towards learning more about it, and then come back to solving this problem, although I must admit it isn't a particularly tempting endeavor. I'm also struggling to understand whether we're dealing with a problem in gensim proper, or if it's a problem with the feedstock (https://github.com/conda-forge/gensim-feedstock/). |
I believe @gojomo has used it. I guess having binary wheels for Windows fixes most of such issues – we can now just tell people to do |
+1 @gojomo @menshikh-iv Any thoughts? |
@mpenkov up to you, |
I wonder if we can find a conda zealot who is willing to maintain the feedstock officially. Essentially, a new maintainer for https://github.com/conda-forge/gensim-feedstock/ and a go-to person for conda issues... |
I think there are 3 ways to install Gensim in the conda ecosystem:
Though I may have messed that up completely! Someone correct me. |
I usually like to use (mini)conda to manage my dev environment. (The 'mini' version because I don't want the installation-overhead/complexity/etc of the full 'anaconda' package set.) I tend to install jupyter, numpy, scipy via the native So from my perspective: We don't have to do any extra conda-work, or worry about other 'conda-forge' repos, or whatever – just encourage people to use (But also: this all seems a digression from what I see as the real reason for this bug-report: tiny behavioral differences between the 'optimized' and 'pure-python' paths, plus other recurring issues where the optimized code isn't available. Dropping the pure-python paths entirely will simplify maintenance immensely, though the code would then be less useful as a teaching tool.) |
As we no longer have the possibly-divergent pure-Python paths, I don't think this should recur. If that assumption is wrong, feel free to re-open w/ details. |
Hi all,
I trained a
Doc2Vec
model successfully with the data of the Kaggle Tutorial "Bag of Words Meets Bags of Popcorn" https://www.kaggle.com/c/word2vec-nlp-tutorial/data. The methodsmost_similar
anddoesnt_match
are working like expected.However, when I use the
infer_vector
method, the error AttributeError: 'Doc2Vec' object has no attribute 'syn1' arises. When I check the model, there is just an model.syn0 available.Systeminfo
MacOSX 10.10.5,
Python 2.7.10
Packages (I don't use Cyclone at the moment...)
boto (2.38.0)
bz2file (0.98)
gensim (0.12.2)
httpretty (0.8.6)
numpy (1.10.1)
pip (7.1.2)
requests (2.8.1)
scipy (0.16.0)
setuptools (18.2)
six (1.10.0)
smart-open (1.3.0)
wheel (0.24.0
Example in IPython
THX for your Help! :)
The text was updated successfully, but these errors were encountered: