topical_word_embeddings icon indicating copy to clipboard operation
topical_word_embeddings copied to clipboard

twe-1: in except-except branch, train_sentence_topic not defined

Open makrai opened this issue 9 years ago • 4 comments

topical_word_embeddings/TWE-1/gensim/models/word2vec.py", line 901 NameError: global name 'train_sentence_topic' is not defined

makrai avatar Feb 18 '16 15:02 makrai

I meet the same error.

Hellokitty8 avatar Mar 07 '17 08:03 Hellokitty8

I also met the same error.

oppsitre avatar Mar 29 '17 10:03 oppsitre

You may notice the 'word2vec_inner.pyx' file. This is the code of cython which have been modified by author. You need to compile it at first, then you can import 'train_sentence_topic' defined in it.
Give more hints you may feel useful when running code.

  1. In all three models, author have modified the source code of gensim and included them, so you needn't to install the gensim by yourself.
  2. I failed to compile the word2vec_inner.pyx.pyx in the original folder. Then I only copied the word2vec_inner.pyx and head file to new folder. It succeed this time.
  3. If you have compiled the *.pyx, only import the word2_inner.pyx is enough. You can delete import 'pyximport' that can prevent some errors.
  4. When compiling *.pyx, you may meet the the error of scipy ‘from scipy.... import fabls’, it may happen for the version of scipy. You can change the code, in word2vec_inner.pyx, 'from 'scipy.linalg.blas import fblas' to 'import scipy.linalg.blas as fblas'

oppsitre avatar Apr 02 '17 14:04 oppsitre

Speaking of the cython issue: When I try to compile word2vec_inner.pyx, I get the following issue:

Error compiling Cython file:
------------------------------------------------------------
...
                k = sentence_len
            for j in range(j, k):
                if j == i or codelens[j] == 0:
                    continue
                if hs:
                    fast_sentence_topic(points[i], codes[i], codelens[i], syn0, syn1, syn0_topic, size, topic[j], _alpha, work)
                                                                                                            ^
------------------------------------------------------------

word2vec_inner.pyx:890:109: Cannot assign type 'uint32_t *' to 'uint32_t'

has anyone seen this before or know how to resolve it?

I already tried the fixes above and it seems like this issue is stopping me from running the code.

akornilo avatar Sep 02 '17 00:09 akornilo