Comments (6)
Hi Junpeng, that's a great question! The install works for me just running "!pip3 install tfp-nightly" -- I believe the '--user' flag isn't necessary in colab since everything is run in a sandbox by default. However, once installed, I'm seeing the import itself still fail with "ImportError: cannot import name 'seed_stream'" from tensorflow.contrib.distributions.python.ops, which seems to indicate that Colab is preferring its own version of TensorFlow over the nightly package which TFP depends on.
We're certainly interested in making sure TFP works from Colab; we'll engage with the Colab team internally to work this out, and keep you posted. If you or anyone else discovers a workaround in the meantime, feel free to share!
from probability.
After some discussion with the Colab team: there's a TF release bug that's causing Python 3 colabs to pull in an outdated version of tf-nightly
. When this is fixed, !pip install tfp-nightly
will work in Python 3 colabs just as it currently does in Python 2 colabs.
(in the slightly longer term we hope to include TFP in the default colab install, but this should wait until we have a release that depends on stable Tensorflow).
from probability.
For what it's worth, using a Python2.7 colab seems to work fine for me, running "!pip install tfp-nightly", so that's an (admittedly imperfect) potential workaround.
from probability.
It looks like the Colabs now update with more up-to-date TFP packages. This one can probably be closed.
from probability.
On Google Colab Python 2 without GPU, I run
!pip install --upgrade tfp-nightly
Then in import tensorflow as tf
I got the error in #46.
In import tensorflow_probability as tfp
, I got
ImportErrorTraceback (most recent call last)
<ipython-input-2-41494c8c96ff> in <module>()
----> 1 import tensorflow_probability as tfp
/usr/local/lib/python2.7/dist-packages/tensorflow_probability/__init__.py in <module>()
19
20 # from tensorflow_probability.google import staging # DisableOnExport
---> 21 from tensorflow_probability.python import * # pylint: disable=wildcard-import
/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/__init__.py in <module>()
19 from __future__ import print_function
20
---> 21 from tensorflow_probability.python import distributions
22 from tensorflow_probability.python import edward2
23 from tensorflow_probability.python import glm
/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/__init__.py in <module>()
20 # pylint: disable=unused-import,line-too-long,g-importing-member
21
---> 22 from tensorflow_probability.python.distributions import bijectors
23
24 from tensorflow_probability.python.distributions.autoregressive import Autoregressive
/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/bijectors/__init__.py in <module>()
21 # pylint: disable=unused-import,wildcard-import,line-too-long,g-importing-member
22
---> 23 from tensorflow_probability.python.distributions.bijectors.absolute_value import AbsoluteValue
24 from tensorflow_probability.python.distributions.bijectors.affine import Affine
25 from tensorflow_probability.python.distributions.bijectors.affine_linear_operator import AffineLinearOperator
/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/bijectors/absolute_value.py in <module>()
19 from __future__ import print_function
20
---> 21 import tensorflow as tf
22 from tensorflow.python.ops import control_flow_ops
23 from tensorflow.python.ops.distributions import bijector
/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py in <module>()
20
21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
23 from . import app
24 from . import bitwise
/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
ImportError: cannot import name pywrap_tensorflow
On Google Colab Python 3 without GPU, I do the same thing.
Not sure why, after !pip
, I need to "Restart runtime..." before import tensorflow and tensorflow_probability. Then I can successfully import them without the errors appear in Python 2 Colab.
from probability.
FYI: TFP releases are now installed by default in Colab, so import tensorflow_probability as tfp
should 'just work' now without any installation steps.
Closing this issue; feel free to reopen if you run into problems.
from probability.
Related Issues (20)
- Dirichlet distribution sampling issue when jit_compile=True HOT 1
- AttributeError: 'SymbolicTensor' object has no attribute 'log_prob' when exporting train signature with `IndependentNormal` layer HOT 1
- Add Poisson quantile
- Computing log_prob for tfd.Sample() with a different number of samples
- TruncatedCauchy gives wrong results sometimes
- `_parameter_properties` is not implemented for `LinearGaussianStateSpaceModel`
- tensorflow 2.16.1 breaks tensorflow-probability with Keras `3.0` API HOT 3
- `LinearGaussianStateSpaceModel` filtering initial state is incorrect
- Piecewise distribution
- Keras not accepting character `/` from build_factored_surrogate_posterior HOT 4
- A bug in Linear_Mixed_Effects_Models.ipynb
- Conditional input with multiple flows HOT 1
- mlx backend HOT 1
- Can't jit PoissonLogNormalQuadratureCompound log_prob
- autobnn error HOT 2
- Addition of "location" type parameter in the Gamma distribution HOT 2
- Unexpected Symbolic tensor in Tensorflow Probability tensor_coercible object (mixture layer)
- TFP JAX: The transition kernel drastically decreases speed.
- jax.dtypes.prng_key gives `AttributeError: module 'jax.dtypes' has no attribute 'prng_key'` HOT 1
- MultivariateNormalTriL Layer appears to be incompatible with tf.keras in tf 2.16.1 and tfp 0.24 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from probability.