LDA example gives an Error

Im trying to run the lda example in ipython notebook. However, when I run the inference, I get following error.

Average Loss = 3.5339e+06:   0%|          | 2/10000 [00:00<11:23, 14.62it/s]
Traceback (most recent call last):
  File "/home/nadheesh/PycharmProjects/bayesian_learning/batch/lda.py", line 180, in <module>
    more_replacements={doc_t:doc_t_minibatch})
  File "/home/nadheesh/anaconda3/envs/dev/lib/python3.5/site-packages/pymc3/variational/inference.py", line 135, in fit
    state = self._iterate_with_loss(0, n, step_func, progress, callbacks)
  File "/home/nadheesh/anaconda3/envs/dev/lib/python3.5/site-packages/pymc3/variational/inference.py", line 181, in _iterate_with_loss
    raise FloatingPointError('NaN occurred in optimization.')
FloatingPointError: NaN occurred in optimization.

Why does this error occurs? Does anyone know how to fix it?

Thanks

I have no problem running the example notebook, are you running on a different dataset? You can try to play around with the learning rate in obj_optimizer=pm.sgd(learning_rate=s).

I’m using the same dataset and the same script without any changes.

I tried changing the learning rate but still I get the error.

I use,

  • PyMC3 v3.4.1
  • Theano v1.0.1

with python v3.5.4

Could you please try upgrading to the newest version of PyMC3? Not sure why this is happening as I cannot reproduce it…

1 Like