问题
i'm trying to generate seed using TensorFlow 2.1 but this error appears module 'TensorFlow' has no attribute 'random'
回答1:
I suspect that you think you're using TensorFlow 2.0 but actually, it is a previous version of tensorflow.
It's easy to check:
import tensorflow as tf
print(tf.__version__)
This should produce output like this:
2.1.0
If not, you know you have the wrong TensorFlow version installed.
It's also possible that you have multiple versions of python installed. For example:
- Python 3.6 might be installed with TensorFlow 1.x, and
- Python 3.7 might be installed with TensorFlow 2.x.
In this case, just be careful that the version of Python being used by Jupyter Notebook is the version of Python with TensorFlow 2.x installed.
回答2:
just want to make sure
run this command then restart the runtime pip install --upgrade tensorflow
and then try that code again
来源:https://stackoverflow.com/questions/60575143/module-tensorflow-has-no-attribute-random