Python TensorFlow SavedModel导出失败,AttributeError为

Python TensorFlow SavedModel导出失败,AttributeError为,python,tensorflow,keras,Python,Tensorflow,Keras,我完全按照这里的教程进行操作: 最后,如果我想使用model.save()从本教程导出经过训练的模型,我会收到以下错误消息: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-19-768eb5acd4e8&g

我完全按照这里的教程进行操作:

最后,如果我想使用
model.save()
从本教程导出经过训练的模型,我会收到以下错误消息:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-768eb5acd4e8> in <module>()
      3 
      4 export_path = "/tmp/saved_models/{}".format(int(t))
----> 5 model.save(export_path, save_format='tf')

4 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/network.py in save(self, filepath, overwrite, include_optimizer, save_format, signatures, options)
    984     """
    985     saving.save_model(self, filepath, overwrite, include_optimizer, save_format,
--> 986                       signatures, options)
    987 
    988   def save_weights(self, filepath, overwrite=True, save_format=None):

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/save.py in save_model(model, filepath, overwrite, include_optimizer, save_format, signatures, options)
    113   else:
    114     saved_model_save.save(model, filepath, overwrite, include_optimizer,
--> 115                           signatures, options)
    116 
    117 

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saved_model/save.py in save(model, filepath, overwrite, include_optimizer, signatures, options)
     72   # default learning phase placeholder.
     73   with K.learning_phase_scope(0):
---> 74     save_lib.save(model, filepath, signatures, options)
     75 
     76   if not include_optimizer:

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/saved_model/save.py in save(obj, export_dir, signatures, options)
    905   # Note we run this twice since, while constructing the view the first time
    906   # there can be side effects of creating variables.
--> 907   _ = _SaveableView(checkpoint_graph_view)
    908   saveable_view = _SaveableView(checkpoint_graph_view)
    909 

/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/saved_model/save.py in __init__(self, checkpoint_view)
    189           concrete_functions = [function]
    190         for concrete_function in concrete_functions:
--> 191           if concrete_function.name not in seen_function_names:
    192             seen_function_names.add(concrete_function.name)
    193             self.concrete_functions.append(concrete_function)

AttributeError: 'NoneType' object has no attribute 'name'
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在()
3.
4 export_path=“/tmp/saved_models/{}”。格式(int(t))
---->5 model.save(导出路径,保存格式='tf')
4帧
/保存中的usr/local/lib/python3.6/dist-packages/tensorflow\u core/python/keras/engine/network.py(self、filepath、overwrite、include\u优化器、保存格式、签名、选项)
984     """
985保存。保存\u模型(自我、文件路径、覆盖、包含\u优化器、保存\u格式、,
-->986(签名、选项)
987
988 def保存权重(self、filepath、overwrite=True、save_format=None):
/save_模型中的usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/save.py(模型、文件路径、覆盖、包含_优化器、保存_格式、签名、选项)
113其他:
114保存的\u模型\u保存。保存(模型、文件路径、覆盖、包含\u优化器、,
-->115个签名、选项)
116
117
/保存中的usr/local/lib/python3.6/dist-packages/tensorflow\u core/python/keras/saving/saved\u model/save.py(模型、文件路径、覆盖、包含\u优化器、签名、选项)
72#默认学习阶段占位符。
73 K.学习阶段范围(0):
--->74保存库保存(模型、文件路径、签名、选项)
75
76如果不包括_优化器:
/保存中的usr/local/lib/python3.6/dist-packages/tensorflow_core/python/saved_model/save.py(obj、export_dir、签名、选项)
905#注意,我们在第一次构建视图时运行了两次
906#创建变量可能会产生副作用。
-->907=可保存视图(检查点图视图)
908可保存视图=_可保存视图(检查点图视图)
909
/usr/local/lib/python3.6/dist-packages/tensorflow\u core/python/saved\u model/save.py in\uuuuuuuu init\uuuuuuuu(self,checkpoint\u视图)
189个具体的函数=[函数]
190对于具体函数中的具体函数:
-->191如果具体的函数名不在函数名中:
192 seed\u function\u names.add(具体的\u function.name)
193 self.concrete_functions.append(concrete_function)
AttributeError:“非类型”对象没有属性“名称”

发生了什么事?难道不能简单地将此模型导出到
SavedModel
格式吗?

尽量不要使用
save\u format='tf'
,因为它仍然是根据文档进行实验的。谢谢,尝试了此操作,但仍然会出现相同的错误。我想知道这是否与Keras模型中的集线器层有关?有些事情不是这样的在函数尝试使用
concrete\u函数时解决它。name
不存在,即
NoneType
。请尝试将其发布在Tensorflow或Keras github问题上。