lda2vec icon indicating copy to clipboard operation
lda2vec copied to clipboard

TypeError: only length-1 arrays can be converted to Python scalars

Open nipunsadvilkar opened this issue 9 years ago • 0 comments

I am this getting error while executing your 20newsgroups ipython notebook.

I am running this notebook on remote ipython notebook server.

Also, I got Memoryerror while executing code under Preprocess text section.

and further while executing Fit the model section I got the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-c243e820b33b> in <module>()
      1 # Fit the model
----> 2 model = LDA2Vec(n_words, n_hidden, counts, dropout_ratio=0.2)
      3 model.add_categorical_feature(n_docs, n_topics, name='document_id')
      4 model.finalize()
      5 if os.path.exists('model.hdf5'):

/home/nipunsadvilkar/notebooks/lda2vec_model.pyc in __init__(self, n_documents, n_document_topics, n_units, n_vocab, dropout_ratio, train, counts, n_samples, word_dropout_ratio)
     16                  counts=None, n_samples=15, word_dropout_ratio=0.0):
     17         em = EmbedMixture(n_documents, n_document_topics, n_units,
---> 18                           dropout_ratio=dropout_ratio)
     19         kwargs = {}
     20         kwargs['mixture'] = em

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/embed_mixture.pyc in __init__(self, n_documents, n_topics, n_dim, dropout_ratio)
     66         self.n_dim = n_dim
     67         self.dropout_ratio = dropout_ratio
---> 68         factors = _orthogonal_matrix((n_topics, n_dim)).astype('float32')
     69         factors /= np.sqrt(n_topics + n_dim)
     70         super(EmbedMixture, self).__init__(

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/embed_mixture.pyc in _orthogonal_matrix(shape)
     10     # github.com/mila-udem/blocks/blob/master/blocks/initialization.py
     11     M1 = np.random.randn(shape[0], shape[0])
---> 12     M2 = np.random.randn(shape[1], shape[1])
     13 
     14     # QR decomposition of matrix with entries in N(0, 1) is random

mtrand.pyx in mtrand.RandomState.randn (numpy/random/mtrand/mtrand.c:17781)()

mtrand.pyx in mtrand.RandomState.standard_normal (numpy/random/mtrand/mtrand.c:18260)()

mtrand.pyx in mtrand.cont0_array (numpy/random/mtrand/mtrand.c:2055)()

TypeError: only length-1 arrays can be converted to Python scalars

Also why does it raises error while importing LDA2Vec fuction.

nipunsadvilkar avatar Apr 06 '16 11:04 nipunsadvilkar