模块 'tensorflow' 没有属性 'random' [英] module 'tensorflow' has no attribute 'random'

查看:89
本文介绍了模块 'tensorflow' 没有属性 'random'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 TensorFlow 2.1 生成种子,但出现此错误 module 'TensorFlow' has no attribute 'random'

i'm trying to generate seed using TensorFlow 2.1 but this error appears module 'TensorFlow' has no attribute 'random'

推荐答案

我怀疑您认为您使用的是 TensorFlow 2.0,但实际上,它是 tensorflow 的先前版本.

I suspect that you think you're using TensorFlow 2.0 but actually, it is a previous version of tensorflow.

很容易检查:

import tensorflow as tf
print(tf.__version__)

这应该产生如下输出:

2.1.0

如果没有,您就知道您安装了错误的 TensorFlow 版本.

If not, you know you have the wrong TensorFlow version installed.

也有可能你安装了多个版本的 python.例如:

It's also possible that you have multiple versions of python installed. For example:

  • Python 3.6 可能与 TensorFlow 1.x 一起安装,并且
  • Python 3.7 可能与 TensorFlow 2.x 一起安装.

在这种情况下,请注意 Jupyter Notebook 使用的 Python 版本是安装了 TensorFlow 2.x 的 Python 版本.

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.

这篇关于模块 'tensorflow' 没有属性 'random'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆