module 'tensorflow' has no attribute 'random'

我怕爱的太早我们不能终老 提交于 2021-01-29 14:39:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!