没有名为 tensorflow.contrib 的模块 [英] no module named tensorflow.contrib
问题描述
我在导入 tensorflow.contrib.slim 时遇到了这个问题
I have this problem when I import tensorflow.contrib.slim
import tensorflow.contrib.slim as slim
我收到此错误消息
Traceback (most recent call last):
File "/home/toshiba/PFE/DocFace-master/src/tflib.py", line 28, in <module>
import tensorflow.contrib.slim as slim
ModuleNotFoundError: No module named 'tensorflow.contrib'
tensorflow 安装正确,我发现一些解决方案说文件名是 tensorflow 所以它会导致问题,但这里不是这种情况
tensorflow is correctly installed and i found some solutions that said that the file name is tensorflow so it causes the problem but that is not the case in here
推荐答案
您可能安装了 TensorFlow 版本 2.*,但 tf.contrib.slim
是 TensorFlow 1.15 代码.您可以在此处查看如何将现有代码迁移到 tensorflow 2.*.
You probably have TensorFlow version 2.* installed, but tf.contrib.slim
is TensorFlow 1.15 code. You can check here how to migrate your existing code to tensorflow 2.*.
如果您想保留代码,可以通过在命令行中输入 pip install tensorflow==1.15
降级到 TensorFlow 以降级到 TensorFlow 1.15.
If you instead want to keep your code, you can downgrade to TensorFlow by typing pip install tensorflow==1.15
into your command-line to downgrade to TensorFlow 1.15.
这篇关于没有名为 tensorflow.contrib 的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!