module 'tensorflow' has no attribute '_version_'
时间: 2023-04-29 16:03:09 浏览: 191
这个错误提示是因为 TensorFlow 模块中没有名为 _version_ 的属性。可能是因为你的 TensorFlow 版本过低或者安装不完整导致的。建议升级 TensorFlow 或者重新安装 TensorFlow。
相关问题
module pyarrow has no attribute __version__
这个问题可能是因为您的 PyArrow 版本较老,不支持 __version__ 属性。请尝试升级 PyArrow 到最新版本,然后再次尝试查看 __version__ 属性。您可以使用以下命令升级 PyArrow:
```
pip install --upgrade pyarrow
```
如果您已经安装了最新版本的 PyArrow,但仍然无法查看 __version__ 属性,那么可能是因为您的 PyArrow 安装出现了问题。您可以尝试重新安装 PyArrow,或者使用其他方式获取 PyArrow 版本信息。
module tensorflow has no attribute Session
This error usually occurs when the TensorFlow version is 2.x and the code is written in the TensorFlow 1.x style, which is different. In TensorFlow 2.x, the eager execution mode is enabled by default, which means that you don't need to explicitly create a session object.
To resolve this error, you can modify your code to use the TensorFlow 2.x style, which involves using functions like `tf.function()` for creating graphs and `tf.keras` for building models. If you need to use the session object, you can do so by disabling eager execution mode using `tf.compat.v1.disable_eager_execution()`.
Here's an example of how to create a session object in TensorFlow 2.x:
```
import tensorflow as tf
# disable eager execution mode
tf.compat.v1.disable_eager_execution()
# define a computation graph
a = tf.constant(5)
b = tf.constant(10)
c = tf.multiply(a, b)
# create a session object
sess = tf.compat.v1.Session()
# run the computation graph
result = sess.run(c)
print(result)
# close the session
sess.close()
```
阅读全文