Probability: tfp-nightly import with TensorFlow 2.0 Alpha

Created on 2 Jun 2019  Â·  6Comments  Â·  Source: tensorflow/probability

I was trying to use tfp-nightly with tf 2.0 on Google Colab.

! pip install tensorflow==2.0.0-alpha0
! pip install tfp-nightly
import tensorflow_probability as tfp

This gives me the error below:

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/__init__.py in <module>()
     73 
     74 # from tensorflow_probability.google import staging  # DisableOnExport
---> 75 from tensorflow_probability.python import *  # pylint: disable=wildcard-import
     76 from tensorflow_probability.python.version import __version__
     77 # pylint: enable=g-import-not-at-top

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/python/__init__.py in <module>()
     25 from tensorflow_probability.python import experimental
     26 from tensorflow_probability.python import glm
---> 27 from tensorflow_probability.python import layers
     28 from tensorflow_probability.python import math
     29 from tensorflow_probability.python import mcmc

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/python/layers/__init__.py in <module>()
     29 from tensorflow_probability.python.layers.dense_variational import DenseReparameterization
     30 from tensorflow_probability.python.layers.dense_variational_v2 import DenseVariational
---> 31 from tensorflow_probability.python.layers.distribution_layer import CategoricalMixtureOfOneHotCategorical
     32 from tensorflow_probability.python.layers.distribution_layer import DistributionLambda
     33 from tensorflow_probability.python.layers.distribution_layer import IndependentBernoulli

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/python/layers/distribution_layer.py in <module>()
     37 from tensorflow_probability.python.internal import distribution_util as dist_util
     38 from tensorflow_probability.python.layers.internal import distribution_tensor_coercible as dtc
---> 39 from tensorflow_probability.python.layers.internal import tensor_tuple as tensor_tuple
     40 from tensorflow.python.keras.utils import tf_utils as keras_tf_utils  # pylint: disable=g-direct-tensorflow-import
     41 

/usr/local/lib/python3.6/dist-packages/tensorflow_probability/python/layers/internal/tensor_tuple.py in <module>()
     22 
     23 from tensorflow.python.framework import composite_tensor  # pylint: disable=g-direct-tensorflow-import
---> 24 from tensorflow.python.framework import type_spec  # pylint: disable=g-direct-tensorflow-import
     25 
     26 

ImportError: cannot import name 'type_spec'

Most helpful comment

Maybe

pip install tf-nightly-2.0-preview

All 6 comments

Maybe

pip install tf-nightly-2.0-preview

Same issue here, I'm assuming those versions of tfp and tf just aren't compatible.

pip install tf-nightly-2.0-preview solved my problem.

TensorFlow Probability 0.7.0-rc0 is compatible with TensorFlow 2.0.0-alpha0 (see correction below).

The nightly TensorFlow Probability package (tfp-nightly) is generally only compatible with nightly TensorFlow 1 or 2 packages (tf-nightly and tf-nightly-2.0-preview).

Correction: 0.7.0-rc0 is compatible with tensorflow==2.0.0b0 and 1.14.0rc0
There are some bugs in 1.14.0rc1, which should be resolved in TF rc2.

Brian Patton | Software Engineer | [email protected]

On Fri, Jun 14, 2019 at 3:06 PM Jacob Burnim notifications@github.com
wrote:

Closed #443 https://github.com/tensorflow/probability/issues/443.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/probability/issues/443?email_source=notifications&email_token=AFJFSI6N3PO3BZTBVFRS4Y3P2PT4ZA5CNFSM4HSC44DKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOR7V2SBI#event-2414586117,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFJFSI4JA5SEYYV637BSEN3P2PT4ZANCNFSM4HSC44DA
.

I have problems importing tensorflow_probability with tensorflow nightly due to the following error

I installed all dependencies using pip install --upgrade tf-nightly-2.0-preview tfp-nightly

>>> import tensorflow_probability
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/envs/testenv_3.6/lib/python3.6/site-packages/tensorflow_probability/__init__.py", line 68, in <module>
    _ensure_tf_install()
  File "/usr/local/envs/testenv_3.6/lib/python3.6/site-packages/tensorflow_probability/__init__.py", line 58, in _ensure_tf_install
    if (distutils.version.LooseVersion(tf.__version__) <
AttributeError: module 'tensorflow' has no attribute '__version__'

Should I pin against the specific versions or what?

Here is the full pip freeze output

(testenv_3.6) root@74704f48e10e:/opt/pymc4# pip freeze
absl-py==0.7.1
appdirs==1.4.3
astor==0.8.0
astroid==2.2.5
atomicwrites==1.3.0
attrs==19.1.0
black==19.3b0
certifi==2019.6.16
Click==7.0
cloudpickle==1.1.1
coverage==4.5.3
decorator==4.4.0
gast==0.2.2
google-pasta==0.1.7
grpcio==1.22.0
h5py==2.9.0
importlib-metadata==0.18
isort==4.3.21
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
lazy-object-proxy==1.4.1
Markdown==3.1.1
mccabe==0.6.1
more-itertools==7.1.0
numpy==1.16.4
opt-einsum==2.3.2
packaging==19.0
pandas==0.24.2
patsy==0.5.1
pluggy==0.12.0
protobuf==3.9.0
py==1.8.0
pydocstyle==4.0.0
pylint==2.3.1
pymc3==3.7
pyparsing==2.4.0
pytest==5.0.1
pytest-cov==2.7.1
pytest-html==1.21.1
pytest-metadata==1.8.0
python-dateutil==2.8.0
pytz==2019.1
scipy==1.3.0
six==1.12.0
snowballstemmer==1.9.0
tb-nightly==1.15.0a20190716
tensorflow-estimator-2.0-preview==1.14.0.dev2019071600
termcolor==1.1.0
tf-nightly-2.0-preview==2.0.0.dev20190716
tfp-nightly==0.8.0.dev20190716
Theano==1.0.4
toml==0.10.0
tqdm==4.32.2
typed-ast==1.4.0
wcwidth==0.1.7
Werkzeug==0.15.4
wrapt==1.11.2
zipp==0.5.2

Was this page helpful?
0 / 5 - 0 ratings