inspirehep / magpie

Deep neural network framework for multi-label text classification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when update new version of magpie

bigredbug47 opened this issue · comments

Hi guys,

After updated the new version of magpie (v2.1), the old saved model, words vector that created in v2.0 seems can't be loaded in v2.1.

The errors were occurred by gensim library.

    predict_text = magpie.predict_from_text(trans_text)
File "/usr/local/lib/python3.5/dist-packages/magpie/main.py", line 196, in predict_from_text
    return self._predict(doc)
  File "/usr/local/lib/python3.5/dist-packages/magpie/main.py", line 214, in _predict
    word_vector = self.word2vec_model.wv[w].reshape(1, -1)
  File "/usr/local/lib/python3.5/dist-packages/gensim/models/keyedvectors.py", line 353, in __getitem__
    return self.get_vector(entities)
  File "/usr/local/lib/python3.5/dist-packages/gensim/models/keyedvectors.py", line 471, in get_vector
    return self.word_vec(word)
  File "/usr/local/lib/python3.5/dist-packages/gensim/models/keyedvectors.py", line 463, in word_vec
    result = self.vectors[self.vocab[word].index]
AttributeError: 'Word2VecKeyedVectors' object has no attribute 'vectors'

What should we do to load the saved model from v2.0 to use in v2.1?

Thanks for your help.

@bigredbug47 hmmmm, that's interesting. It seems like gensim explodes when we look up a particular word. Does that also happen when you save and read vectors both through v2.1?

Nope @jstypka, it is normal when I save and load in the same version. But can't work when I use them in other version.

We bumped Gensim version quite significantly in the update from v2.0 to v2.1. I didn't expect any issues, but it's highly likely that the vector spaces are incompatible between them. I'll add a note to README! Thanks! 🙏