How to fix 'KeyError: dtype('float32')' in LDAviz

Viewed 577

I use LDAvis library to visualize my LDA topics. It works fine before, but it gets me this error when I download the saved model files from Sagemaker to the local computer. I don't know why does this happen? Does that relate to Sagemaker?

If I run from the local, and saved the model from local, and then run LDAviz library, it works fine.


KeyError Traceback (most recent call last) in ()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyLDAvis\gensim.py in prepare(topic_model, corpus, dictionary, doc_topic_dist, **kwargs) 116 See pyLDAvis.prepare for **kwargs. 117 """ --> 118 opts = fp.merge(_extract_data(topic_model, corpus, dictionary, doc_topic_dist), kwargs) 119 return vis_prepare(**opts)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyLDAvis\gensim.py in _extract_data(topic_model, corpus, dictionary, doc_topic_dists) 46 gamma = topic_model.inference(corpus) 47 else: ---> 48 gamma, _ = topic_model.inference(corpus) 49 doc_topic_dists = gamma / gamma.sum(axis=1)[:, None] 50 else:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\ldamodel.py in inference(self, chunk, collect_sstats) 665 # phinorm is the normalizer. 666 # TODO treat zeros explicitly, instead of adding epsilon? --> 667 eps = DTYPE_TO_EPS[self.dtype] 668 phinorm = np.dot(expElogthetad, expElogbetad) + eps 669

KeyError: dtype('float32')

1 Answers

I know this is late but I just fixed a similar problem by updating my gensim library from 3.4 to the current version which for me is 3.8.

Related