嗨,我刚刚安装Tensorflow在Mac上,想使用,tf.contrib.slim但是当我使用它时,我得到了
import tensorflow as tf
slim = tf.contrib.slim
Run Code Online (Sandbox Code Playgroud)
错误:
来自tensorflow.python.saved_model.model_utils的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/export/export_lib.py”,第25行导入build_all_signature_defs ModuleNotFoundError:没有名为'tensorflow.python.saved_model.model_utils'的模块
我不知道该怎么办,请帮帮我
我用Tensorflow.13.1和python 3.7
Yeh*_*NNA 58
对于那些在github 中尝试一些带有Tensorflow 1.x.x版本的旧代码的人,Tensorflow 2.0.x请注意tf.contrib不再存在Tensorflow 2.0.x并且它的模块被移动了。
请在没有tf.contrib部分的情况下用谷歌搜索模块的名称以了解它的新位置,从而通过更正import语句相应地迁移您的代码。
希望这有帮助!
小智 39
首先卸载 tensorflow
pip uninstall tensorflow
Run Code Online (Sandbox Code Playgroud)
然后安装 1.13.2 版本
pip install tensorflow==1.13.2
Run Code Online (Sandbox Code Playgroud)
它有效..有同样的问题..但安装tensorflow 1.13.2解决了它!
较新版本的 tensorflow 没有
小智 12
如果以下命令不起作用
pip3 install tensorflow==1.14.0
Run Code Online (Sandbox Code Playgroud)
那么我们可以尝试以下命令
pip3 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.14.0-py3-none-any.whl
Run Code Online (Sandbox Code Playgroud)
目前 tensorflow 的默认安装是 2.x,而你的代码是 1.x。contrib 模块已从 tf 2.x 中删除。检查警告:
“TensorFlow contrib 模块将不会包含在 TensorFlow 2.0 中”
卸载 tensorflow 然后安装 1.x 版本
pip install tensorflow==1.15
Run Code Online (Sandbox Code Playgroud)
小智 5
我通过以下方法解决了这个问题。
pip uninstall tensorflow_estimator
pip install tensorflow_estimator
Run Code Online (Sandbox Code Playgroud)
参考是:https : //github.com/tensorflow/tensorflow/issues/27079
小智 5
第一的:
pip install --upgrade tf_slim
Run Code Online (Sandbox Code Playgroud)
然后:
import tf_slim as slim
Run Code Online (Sandbox Code Playgroud)
小智 -4
从 TensorFlow 13.1 开始,没有任何贡献。您可以不使用它slim = tf.slim,也可以安装pip install tensorflow==1.13并使用它