AttributeError: module 'tensorflow' has no attribute 'gfile'
时间: 2023-09-19 14:11:10 浏览: 268
问题解决:module 'tensorflow.compat.v1' has no attribute '
5星 · 资源好评率100%
This error occurs when TensorFlow version 2 or above is being used, and the code is referencing the deprecated module `gfile` from TensorFlow version 1.
To resolve this error, replace `tensorflow.gfile` with `tensorflow.io.gfile` in the code. For example, if the code has the line:
```
import tensorflow as tf
...
with tf.gfile.GFile(filename, 'rb') as f:
...
```
Change it to:
```
import tensorflow as tf
...
with tf.io.gfile.GFile(filename, 'rb') as f:
...
```
This should resolve the error and allow the code to run without issues.
阅读全文