-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
AttributeError: module 'tensorflow' has no attribute 'contrib' #505
Comments
Maybe you Haven't installed Nightly Artifacts of TensorFlow. Nighty Artifacts is one core component in order to use TensorFlow eager Mode
If it doesn't work, then add more detailed version by running the following in a Python shell:
For More Details, you can refer:- TensorFlow Eager Execution |
@jaypatel15406 it's true for colab notebooks too, which say that you don't have to install anything. Simply from TF2.0 there is no contrib module anymore and these notebooks are outdated as far as I'm concerned. See this stack. Can anybody help with it? How to convert them to TF2.0? EDIT: For now, I simply deleted the lines
and repliced them with:
This will disable eager execution and remove dependence on tf.contrib from the code (I hope so, to this moment it did). |
I think @mikeshwe started porting this code to TF2. I'll try to do my best to port the rest of notebooks as I go based on the first one (I committed to learning Bayesian Methods with this practical course). I'll push PRs after each notebook is ported. Should we open another issue for communication? |
Another solution is to downgrade: #502 |
I've got a port that seems to work in TF2, at least for the second chapter, and only in eager mode. However, even running on 2 Tesla T4s the code takes hours to run (so far - my instances keep timing out). I think there's something else gone wrong here. |
ok so rather than add the option for graph mode I've added the @tf.function decorator to all the mcmc.sample_chain calls and the whole thing now runs in about 2 minutes. I'll do some further cleanup (removing the evaluate calls - since just doing .numpy() on the result is about 30% faster and its less confusing), and extend out to the other examples. But should be an easy fix from here on out. |
thank you |
One easy way is you can pass your code written in TensorFlow 1.x to the below code to automatically upgrade it to TensorFlow 2.x.
The above code will replace all the commands which are deprecated in 2.x with the onces that are actually working in 2.x. And then you can run your code in TensorFlow 2.x. In case if it throws an error and is unable to convert the complete code and then don't panic. Please open the "report.txt" file that is generated by the above code. In this file, you will find commands that are deprecated and their alternative commands that can be used in TensorFlow 2.x. Taadaa, just replace the commands that are throwing errors with the new ones. Example: If the command in TensorFlow 1.x is:
Then the same command in Tensorflow 2.x is:
In the above example replace "tf.contrib" with "tf.compat.v1.estimator" and that should solve the problem. |
tensorflow.contrib.eager is no longer in TensorFlow, but it's used in the jupyter notebooks and in google colab.
The text was updated successfully, but these errors were encountered: