Python 导入错误:无法导入名称';导出已保存的模型&x27;

Python 导入错误:无法导入名称';导出已保存的模型&x27;,python,keras,spyder,Python,Keras,Spyder,我现在正在学习深度学习,我正在制作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\tensorfl

我现在正在学习深度学习,我正在制作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后端。
D:\Anaconda install\lib\site packages\tensorflow\python\framework\dtypes.py:516:FutureWarning:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(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:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(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:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(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:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(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:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(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:不推荐将(type,1)或“1type”作为类型的同义词传递;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
np_resource=np.dtype([(“resource”,np.ubyte,1)])
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
从keras.models导入顺序
文件“D:\Anaconda install\lib\site packages\keras\\uuuu init\uuuuuu.py”,第3行,在
从…起导入UTIL
文件“D:\Anaconda install\lib\site packages\keras\utils\\uuuuu init\uuuuu.py”,第6行,在
从…起导入conv_utils
文件“D:\Anaconda install\lib\site packages\keras\utils\conv_utils.py”,第9行,在
从…起将后端导入为K
文件“D:\Anaconda install\lib\site packages\keras\backend\\uuuu init\uuuuuu.py”,第1行,在
from.load\u后端导入epsilon
文件“D:\Anaconda install\lib\site packages\keras\backend\load\u backend.py”,第90行,在
从.tensorflow\u后端导入*
文件“D:\Anaconda install\lib\site packages\keras\backend\tensorflow\u backend.py”,第5行,在
导入tensorflow作为tf
文件“D:\Anaconda install\lib\site packages\tensorflow\\uuuu init\uuuu.py”,第28行,在
从tensorflow.python导入pywrapu tensorflow 35; pylint:disable=未使用的导入
文件“D:\Anaconda install\lib\site packages\tensorflow\python\\uuuu init\uuuu.py”,第83行,在
从tensorflow.python导入keras
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\\ uuuu init\ uuuu.py”,第26行,在
从tensorflow.python.keras导入激活
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\activations.py”,第24行,在
从tensorflow.python.keras.utils.generic\u utils导入反序列化\u keras\u对象
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\utils\\uuuuu init\uuuu.py”,第39行,在
从tensorflow.python.keras.utils.multi_gpu utils导入multi_gpu模型
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\utils\multi\u gpu\u utils.py”,第22行,在
来自tensorflow.python.keras.engine.training导入模型
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\engine\training.py”,第40行,在
来自tensorflow.python.keras.engine导入网络
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\engine\network.py”,第39行,在
从tensorflow.python.keras导入保存
文件“D:\Anaconda install\lib\site packages\tensorflow\python\keras\saving\\ uuu init\ uu.py”,第33行,在
从tensorflow.python.keras.saving.saved_model导入导出_saved_model
ImportError:无法从tensorflow.python.keras.saving.saving\u model(D:\Anaconda install\lib\site packages\tensorflow\python\keras\saving\saving\u model\\ uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
我以前从未见过这个错误,如果不解决这个问题,我的课程就无法进步 请帮我解决这个问题。
谢谢

尝试重新安装
tensorflow

pip uninstall -y tensorflow
pip install tensorflow

由于这是一个Anaconda安装,使用conda更新tensorflow可能会更好:
conda update--all
;安装Anaconda并找到正确版本的库来重新创建错误消息听起来很痛苦。我所能说的是,如果我在网上的简短搜索中找到了正确的命令,并且该命令做了我认为它能做的事情,那么它应该可以工作。它拒绝了我的访问,看起来你需要更新你的tensorflow@rzlvmp谢谢!我目前正在更新我的模块!