导入错误:无法导入名称“export_saved_model”
Posted
技术标签:
【中文标题】导入错误:无法导入名称“export_saved_model”【英文标题】:Import Error: cannot import name 'export_saved_model' 【发布时间】:2021-02-19 20:43:05 【问题描述】:我现在正在学习深度学习,并且正在制作 RNN。我的老师说我需要导入 以下库:
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
它给出了输出:
Using TensorFlow backend.
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
D:\Anaconda install\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
File "<ipython-input-3-1b08a8769e32>", line 1, in <module>
from keras.models import Sequential
File "D:\Anaconda install\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "D:\Anaconda install\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "D:\Anaconda install\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "D:\Anaconda install\lib\site-packages\keras\backend\__init__.py", line 1, in <module>
from .load_backend import epsilon
File "D:\Anaconda install\lib\site-packages\keras\backend\load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "D:\Anaconda install\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "D:\Anaconda install\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "D:\Anaconda install\lib\site-packages\tensorflow\python\__init__.py", line 83, in <module>
from tensorflow.python import keras
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\activations.py", line 24, in <module>
from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\utils\__init__.py", line 39, in <module>
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
from tensorflow.python.keras.engine.training import Model
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\engine\training.py", line 40, in <module>
from tensorflow.python.keras.engine import network
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\engine\network.py", line 39, in <module>
from tensorflow.python.keras import saving
File "D:\Anaconda install\lib\site-packages\tensorflow\python\keras\saving\__init__.py", line 33, in <module>
from tensorflow.python.keras.saving.saved_model import export_saved_model
ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model' (D:\Anaconda install\lib\site-packages\tensorflow\python\keras\saving\saved_model\__init__.py)
我以前从未见过此错误,如果不解决此问题,我将无法继续学习 请帮我解决这个问题。 谢谢!
【问题讨论】:
看来你需要更新你的 tensorflow github.com/tensorflow/models/issues/8450 @rzlvmp 谢谢!我目前正在更新我的模块! 【参考方案1】:尝试重新安装tensorflow
pip uninstall -y tensorflow
pip install tensorflow
【讨论】:
由于这是 Anaconda 安装,使用 conda 更新 tensorflow 可能会更好:conda update --all
。
我没有测试过;安装 Anaconda 并找到正确版本的库来重新创建错误消息听起来很痛苦。我只能说它应该工作,如果我从网上的简短搜索中找到正确的命令,并且该命令执行我认为的操作。
拒绝访问以上是关于导入错误:无法导入名称“export_saved_model”的主要内容,如果未能解决你的问题,请参考以下文章
Python 导入错误:无法从“sklearn.externals”导入名称“六”
AWS Lambda python 错误:Runtime.ImportModuleError:无法导入模块“app”:无法从“pyparsing”导入名称“operatorPrecedence”