CamDavidsonPilon / Probabilistic-Programming-and-Bayesian-Methods-for-Hackers

aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
MIT License
26.71k stars 7.88k forks source link

Ch2 TFP - AttributeError: module 'tensorflow' has no attribute 'contrib' #502

Closed RyanMarten closed 4 years ago

RyanMarten commented 4 years ago

https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter2_MorePyMC/Ch2_MorePyMC_TFP.ipynb

In the Tensorflow port of Chapter 2, there is an error when the first cell in run:

AttributeError                            Traceback (most recent call last)
<ipython-input-1-103d57c84299> in <module>()
     38 
     39 import tensorflow as tf
---> 40 tfe = tf.contrib.eager
     41 
     42 # Eager Execution

AttributeError: module 'tensorflow' has no attribute 'contrib'
cyniphile commented 4 years ago

@RyanMarten The notebooks need to be upgraded to the latest versions of tf and tfp, which Collab uses by default. If you downgrade the versions in Collab with the following code, the notebook works:

!pip install tensorflow==1.13.1
!pip install tensorflow-probability==0.6.0