I am trying to install tensorflow probability on MacOS 10.13.4. I am using python 3.5.6 in Conda. WIth tensorflow version 1.12 (installed using pip ) and tensorflow-probability version 0.5.0 (pip install --upgrade tensorflow-probability). I obtained the following error. I am a github newbie, so appreciate any help!
```
import tensorflow as tf
import tensorflow_probability as tfp
Traceback (most recent call last):
File "", line 1, in
File "/Users/claudiashi/.local/lib/python3.5/site-packages/tensorflow_probability/__init__.py", line 78, in
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "/Users/claudiashi/.local/lib/python3.5/site-packages/tensorflow_probability/python/__init__.py", line 25, in
from tensorflow_probability.python import layers
File "/Users/claudiashi/.local/lib/python3.5/site-packages/tensorflow_probability/python/layers/__init__.py", line 30, in
from tensorflow_probability.python.layers.distribution_layer import CategoricalMixtureOfOneHotCategorical
File "/Users/claudiashi/.local/lib/python3.5/site-packages/tensorflow_probability/python/layers/distribution_layer.py", line 47, in
keras_tf_utils.register_symbolic_tensor_type(
AttributeError: module 'tensorflow.python.keras.utils.tf_utils' has no attribute 'register_symbolic_tensor_type'```
This is a little odd, since 0.5.0 doesn't have distribution_layer.py in its tree (it'll be in 0.6.0). Somehow you're installing a development version of TensorFlow Probability, but I can't fathom how that could happen.
I got same problem. any solutions? Thanks!
I had the same problem. If I install tensorflow_probability with the master branch either implicit:
git clone [email protected]:tensorflow/probability.git
or explicit:
git clone -b master --single-branch [email protected]:tensorflow/probability.git
calling python3 probability/tensorflow_probability/examples/vae.py gives:
Traceback (most recent call last):
File "probability/tensorflow_probability/examples/vae.py", line 123, in <module>
import tensorflow_probability as tfp
File "~/probability/tensorflow_probability/__init__.py", line 78, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "~/probability/tensorflow_probability/python/__init__.py", line 25, in <module>
from tensorflow_probability.python import layers
File "~/probability/tensorflow_probability/python/layers/__init__.py", line 30, in <module>
from tensorflow_probability.python.layers.distribution_layer import CategoricalMixtureOfOneHotCategorical
File "~/probability/tensorflow_probability/python/layers/distribution_layer.py", line 49, in <module>
keras_tf_utils.register_symbolic_tensor_type(
AttributeError: module 'tensorflow.python.keras.utils.tf_utils' has no attribute 'register_symbolic_tensor_type'
If I pull the code from the r0.5 branch (i.e., 0.5 release):
git clone -b r0.5 --single-branch [email protected]:tensorflow/probability.git
calling vae.py does not cause this error:
Downloading http://www.cs.toronto.edu/~larocheh/public/datasets/binarized_mnist/binarized_mnist_train.amat to /tmp/vae/data/binarized_mnist_train.amat
...
It seems that master has code referring to incompatible versions.
The way it works is that our stable releases (e.g. 0.5), are tested and work with the most stable version of TensorFlow at the time of release (e.g. 0.5 works with 1.12). For the master branch, we actually test with the TensorFlow nightly releases (at the time the commit is merged).
So, as an alternative to downgrading to TFP 0.5, you can upgrade TF to nightly and use TFP master branch (with all the caveats of the master and nightly).
Thanks @SiegeLordEx. I believe your answer explains the problem and closes the issue. @claudiashi57 and @tzrtzr000, does that solution work for you?
I am getting the same error with:
$ pip list | grep tensor
tensorboard 1.12.2
tensorflow 1.12.0
tensorflow-probability 0.5.0
@cottrell I have the same version numbers, except that I installed tensorflow-probability with git clone instead of pip. Would that make a difference? Can you try that?
git clone -b r0.5 --single-branch [email protected]:tensorflow/probability.git
@cottrell your grep will miss tf-nightly and tfp-nightly which are where the distribution_layer.py code would exist if it were on your system. Please ensure you are only using tfp-nightly with tf-nightly (or tf-nightly-gpu), or using tensorflow-probability with tensorflow (or tensorflow-gpu). Having both nightly and stable installed will cause compatibility problems.
Ahhh, yes I missed that name diff. Saved me lots of time. Now seems to be working on
$ pip list | grep tf
tf-estimator-nightly 1.13.0.dev2019012901
tf-nightly-gpu 1.13.0.dev20190130
tfp-nightly-gpu 0.6.0.dev20181031
Ah, note also that we stopped building a GPU-specific tfp-nightly package. The one you have is from last October. Instead, now you should just install tf-nightly-gpu (if you want gpu support) and then install tfp-nightly. If you have an old tfp-nightly-gpu build installed (it appears you do) pip uninstall it and then install tfp-nightly.
sorry for the confusion there. TF is eventually going to move away from having separate versions for CPU and GPU; meanwhile downstream packages like TFP have stopped building separate GPU versions.
Thanks, I think you are part of tf core team? It might be worth pasting that to the https://www.tensorflow.org/probability/install page to cut down on the noise from chumps like me :) not sure if that is tightly controlled or what.
And for the record, that is now:
pip list | grep tf
tf-estimator-nightly 1.13.0.dev2019012901
tf-nightly-gpu 1.13.0.dev20190130
tfp-nightly 0.7.0.dev20190130
Can you try TF 1.13, latest tfp, reopen if still an issue?
Yes, I succeeded in running vae.py with TF 1.13 and branch r0.6:
git clone -b r0.6 --single-branch [email protected]:tensorflow/probability.git
Branch r0.7 requires TF 1.14. Branch master throws the error mentioned in this issue:
Traceback (most recent call last):
File "../probability/tensorflow_probability/examples/vae.py", line 123, in <module>
import tensorflow_probability as tfp
File "/Users/mmorin/code/probability/tensorflow_probability/__init__.py", line 75, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "/Users/mmorin/code/probability/tensorflow_probability/python/__init__.py", line 21, in <module>
from tensorflow_probability.python import bijectors
File "/Users/mmorin/code/probability/tensorflow_probability/python/bijectors/__init__.py", line 23, in <module>
from tensorflow_probability.python.bijectors.absolute_value import AbsoluteValue
File "/Users/mmorin/code/probability/tensorflow_probability/python/bijectors/absolute_value.py", line 21, in <module>
import tensorflow.compat.v2 as tf
ModuleNotFoundError: No module named 'tensorflow.compat.v2'