Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Tensorflow 2.0 #320

Closed
activatedgeek opened this issue Mar 8, 2019 · 18 comments
Closed

Support for Tensorflow 2.0 #320

activatedgeek opened this issue Mar 8, 2019 · 18 comments

Comments

@activatedgeek
Copy link

activatedgeek commented Mar 8, 2019

Unfortunately, I could not find the right api in the docs. Is tfp supported with TF 2.0 alpha?

Versions

tensorflow==2.0.0-alpha0
tensorflow-probability==0.6.0

Code

import tensorflow as tf
import tensorflow_probability as tfp

Error Logs

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-6ad69c3a0ac3> in <module>
      1 import tensorflow as tf
----> 2 import tensorflow_probability as tfp

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/__init__.py in <module>
     76 
     77 # from tensorflow_probability.google import staging  # DisableOnExport
---> 78 from tensorflow_probability.python import *  # pylint: disable=wildcard-import
     79 from tensorflow_probability.python.version import __version__
     80 # pylint: enable=g-import-not-at-top

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/python/__init__.py in <module>
     19 from __future__ import print_function
     20 
---> 21 from tensorflow_probability.python import bijectors
     22 from tensorflow_probability.python import distributions
     23 from tensorflow_probability.python import edward2

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/python/bijectors/__init__.py in <module>
     44 from tensorflow_probability.python.bijectors.masked_autoregressive import MaskedAutoregressiveFlow
     45 from tensorflow_probability.python.bijectors.matrix_inverse_tril import MatrixInverseTriL
---> 46 from tensorflow_probability.python.bijectors.matveclu import MatvecLU
     47 from tensorflow_probability.python.bijectors.normal_cdf import NormalCDF
     48 from tensorflow_probability.python.bijectors.ordered import Ordered

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/python/bijectors/matveclu.py in <module>
     22 
     23 from tensorflow_probability.python.bijectors import bijector
---> 24 from tensorflow_probability.python.math.linalg import lu_reconstruct
     25 from tensorflow_probability.python.math.linalg import lu_solve
     26 

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/python/math/__init__.py in <module>
     20 
     21 from tensorflow_probability.python.math.custom_gradient import custom_gradient
---> 22 from tensorflow_probability.python.math.diag_jacobian import diag_jacobian
     23 from tensorflow_probability.python.math.interpolation import batch_interp_regular_1d_grid
     24 from tensorflow_probability.python.math.interpolation import interp_regular_1d_grid

/usr/local/miniconda3/envs/hmc-tf2/lib/python3.6/site-packages/tensorflow_probability/python/math/diag_jacobian.py in <module>
     22 import tensorflow as tf
     23 
---> 24 tfe = tf.contrib.eager
     25 
     26 __all__ = [

AttributeError: module 'tensorflow' has no attribute 'contrib'
@brianwa84
Copy link
Contributor

brianwa84 commented Mar 8, 2019 via email

@activatedgeek
Copy link
Author

Great! Let me try that out.

@twiecki
Copy link

twiecki commented Mar 9, 2019

I tried it and everything works fine, couldn't see performance regressions.

@lc0
Copy link

lc0 commented Mar 9, 2019

nightly works fine for this case

@ghost
Copy link

ghost commented Mar 10, 2019

TFP nightly should be compatible with TF2. Let us know if you encounter issues. In particular we are still looking for performance regressions.

On Fri, Mar 8, 2019, 2:23 AM Sanyam Kapoor @.***> wrote: Unfortunately, I could not find the right api in the docs. Is tfp supported with TF 2.0 alpha? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#320>, or mute the thread https://github.com/notifications/unsubscribe-auth/AVJZI99sQ6r5m3BR1cjoleSzP3hCyB2qks5vUg_0gaJpZM4bkzPe .

Sorry but TFP does not work at all with TF 2 I still got the same error.

AttributeError: module 'tensorflow' has no attribute 'contrib'
MY TF version:

2.0.0-dev20190309

My TFP version:
tfp.__version__

'0.7.0-dev20190309'

@jvdillon
Copy link
Contributor

jvdillon commented Mar 10, 2019

TFP is TF2 ready!

(We still need to update a few examples, but the core library is tested under TF2!)

Try this:
pip install --upgrade tf-nightly-gpu-2.0-preview tfp-nightly
(Drop the -gpu if you don't have one or want a smaller whl download.)

csuter pushed a commit that referenced this issue Mar 10, 2019
`tf-nightly-2.0-preview`.
Related Issues:
#320
#321
#322
#323

PiperOrigin-RevId: 237698145
@jvdillon
Copy link
Contributor

Please reopen if the above procedure didnt work for you. In the coming days we'll also update the GH home page.

@Xemnas0
Copy link

Xemnas0 commented Apr 17, 2019

When trying to run
pip install --upgrade tf-nightly-2.0-preview tfp-nightly
I get the error
Collecting tf-nightly-2.0-preview
Could not find a version that satisfies the requirement tf-nightly-2.0-preview (from versions: ) No matching distribution found for tf-nightly-2.0-preview
I am using Python 3.7, Tensorflow 2.0.0a0 and Windows 10 build 17763

@csuter
Copy link
Member

csuter commented Apr 17, 2019

here is the list of available 2.0-preview packages: https://pypi.org/project/tf-nightly-2.0-preview/2.0.0.dev20190417/#files

looks like the only windows version only has py 3.6 support

@csuter
Copy link
Member

csuter commented Apr 17, 2019

(note this is a TF issue, not TFP)

@ZIKO94ZIKO
Copy link

ZIKO94ZIKO commented Aug 6, 2019

here is the list of available 2.0-preview packages: https://pypi.org/project/tf-nightly-2.0-preview/2.0.0.dev20190417/#files

looks like the only windows version only has py 3.6 support

when should i put the file??

@kristofgiber
Copy link

Is this (TFP nightly 2.0 preview) still the recommended way with TF2-beta latest version? It's not clear from the post because the original question was for TF2-alpha

@csuter
Copy link
Member

csuter commented Aug 21, 2019

Hi @kristofgiber -- the tensorflow-probability 0.7 release is tested against 2.0.0-beta and should be stable. tfp-nightly is tested against tf-nightly and tf-nightly-2.0-preview and should work with both. Please report any issues you encounter using either combination!

@kristofgiber
Copy link

@csuter Thank you. As I understand one difference between tf2 preview and tf2 is that in tf2 preview eager execution is enabled by default but not in tf2. Do I still have to enable eager execution for tfp 0.7 to work when I use it with tf2?

@csuter
Copy link
Member

csuter commented Aug 21, 2019

We (and TF) recommend the following idiom for starting to adopt TF2

import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()

This should ensure you are getting tf2-style APIs and that the various behavioral differences are enabled. At some point the above will become the default when you import tensorflow but I'm not exactly sure when.

@kristofgiber
Copy link

@csuter Good to know! So by using compat.v2 I should be fine and enabling eager execution is not required for tfp+tf2 combo to work

@steremma
Copy link

Hello, is the nightly version still the only way to import distributions? I am getting the same error as above in TF 2

@brianwa84
Copy link
Contributor

tfp-nightly is still the build I'd recommend using (with tf-nightly or tf-nightly-cpu).

If you want the stable version w/o latest bells & whistles, tensorflow-probability==0.8.0 and tensorflow==1.15.0 or tensorflow==2.0.0 should both work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants