为什么我不能导入 Tensorflow.contrib 我收到 No module named 'tensorflow.python.saved 的错误 [英] Why can I not import Tensorflow.contrib I get an error of No module named 'tensorflow.python.saved

查看:68
本文介绍了为什么我不能导入 Tensorflow.contrib 我收到 No module named 'tensorflow.python.saved 的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 Mac 上安装了 Tensorflow,我想使用 tf.contrib.slim 但是当我使用它时,我得到了这个

Hi I just installed Tensorflow on my Mac and I want to use tf.contrib.slim but when I use it I get this

import tensorflow as tf

slim = tf.contrib.slim

错误:

文件/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/export/export_lib.py",第 25 行,在从 tensorflow.python.saved_model.model_utils import build_all_signature_defs ModuleNotFoundError: No module named'tensorflow.python.saved_model.model_utils'

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/export/export_lib.py", line 25, in from tensorflow.python.saved_model.model_utils import build_all_signature_defs ModuleNotFoundError: No module named 'tensorflow.python.saved_model.model_utils'

我不知道该怎么办,请帮帮我

I don't know what to do, please help me

我使用 Tensorflow.13.1python 3.7

推荐答案

适用于正在尝试使用 Tensorflow 1.xxgithub 中的一些旧代码的任何人 版本同时具有 Tensorflow 2.0.x 请注意 tf.contribTensorflow 2.0.x 中不再存在,并且它的模块被移动.
请在没有 tf.contrib 部分的情况下使用谷歌搜索模块的名称,以了解它的新位置,从而通过更正 import 语句来相应地迁移您的代码.

For anyone who is trying some old codes from github with Tensorflow 1.x.x versions while having Tensorflow 2.0.x please note that tf.contrib no longer exist in Tensorflow 2.0.x and it's modules were moved.
Please google the name of the module without the tf.contrib part to know it's new location and thus migrating your code accordingly by correcting the import statement.

希望这有帮助!

这篇关于为什么我不能导入 Tensorflow.contrib 我收到 No module named 'tensorflow.python.saved 的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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