blei-lab / edward

A probabilistic programming language in TensorFlow. Deep generative models, variational inference.
http://edwardlib.org
Other
4.84k stars 759 forks source link

Unsupervised Learning script fails AttributeError: MixtureGaussian instance has no attribute 'iteritems' #235

Closed rafaelvalle closed 8 years ago

rafaelvalle commented 8 years ago

This happens because the script nor the website follows all library updates. On the website, the class MixtureGaussian uses an old version of log_sum_exp which took two arguments. I'll issue a pull request with the correct script.

## -- End pasted text --
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-87699f9851a6> in <module>()
    136 qsigma = InvGamma(model.K * model.D)
    137
--> 138 inference = ed.MFVI({'pi': qpi, 'mu': qmu, 'sigma': qsigma}, data, model)
    139 inference.run(n_iter=4000, n_samples=50, n_minibatch=10)
    140

/usr/local/lib/python2.7/site-packages/edward/inferences.pyc in __init__(self, *args, **kwargs)
    299     """
    300     def __init__(self, *args, **kwargs):
--> 301         super(MFVI, self).__init__(*args, **kwargs)
    302
    303     def initialize(self, n_samples=1, score=None, *args, **kwargs):

/usr/local/lib/python2.7/site-packages/edward/inferences.pyc in __init__(self, model, variational, data)
    131             according to the Stan program's data block.
    132         """
--> 133         super(VariationalInference, self).__init__(model, data)
    134         self.variational = variational
    135

/usr/local/lib/python2.7/site-packages/edward/inferences.pyc in __init__(self, model, data)
     70         else:
     71             self.data = {}
---> 72             for key, value in six.iteritems(data):
     73                 if isinstance(value, tf.Tensor):
     74                     # If `data` has TensorFlow placeholders, the user

/usr/local/lib/python2.7/site-packages/six.pyc in iteritems(d, **kw)
    597
    598     def iteritems(d, **kw):
--> 599         return d.iteritems(**kw)
    600
    601     def iterlists(d, **kw):

AttributeError: MixtureGaussian instance has no attribute 'iteritems'
dustinvtran commented 8 years ago

This is a result of an API change that rolled out just today. I forgot to re-deploy the website after merging it. Thanks for reminding me! Try installing the latest version (pip install -e "git+https://github.com/blei-lab/edward.git#egg=edward") and running it. Alternatively, you can use the older script which you noted would work as well.

We'll be releasing a new Edward version in the upcoming days with the latest API changes.

rafaelvalle commented 8 years ago

Thanks!