TensorFlow KeyError:使用tf.contrib.predictor.from_saved_model在DNNClassifier上进行预测时的'RegexReplace'

时间:2018-06-12 12:58:13

标签: python tensorflow centos7

我正在尝试恢复估算并对其进行预测。

系统配置: CentOS 7 - x64 - CPU tensorflow == 1.5

这就是我保存估算器DNNClassifier

的方法
 def serving_input_receiver_fn():
      inputs = {"embeddings": tf.placeholder(shape=[None], dtype=tf.string)}
      return tf.estimator.export.ServingInputReceiver(inputs, inputs)

 export_dir = estimator.export_savedmodel(
                 export_dir_base='models/run7',
                 serving_input_receiver_fn=serving_input_receiver_fn)

我使用 tf.contrib.predictor.from_saved_model 重新加载,如下所示

estimator = tf.contrib.predictor.from_saved_model('model/1528805269/')

但是,我在上面的行中收到错误 KeyError:'RegexReplace'

完成错误:

 Traceback (most recent call last):
      File "app.py", line 38, in <module>
        load_model()
      File "app.py", line 21, in load_model
        estimator = tf.contrib.predictor.from_saved_model('model/1528805269/')
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/contrib/predictor/predictor_factories.py", line 129, in from_saved_model
        graph=graph)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/contrib/predictor/saved_model_predictor.py", line 156, in __init__
        loader.load(self._session, tags.split(','), export_dir)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 216, in load
        saver = tf_saver.import_meta_graph(meta_graph_def_to_load, **saver_kwargs)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1838, in import_meta_graph
        **kwargs)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/meta_graph.py", line 660, in import_scoped_meta_graph
        producer_op_list=producer_op_list)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
        return func(*args, **kwargs)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 433, in import_graph_def
        _RemoveDefaultAttrs(op_dict, producer_op_list, graph_def)
      File "/var/www/html/my_project/prj_v4/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 211, in _RemoveDefaultAttrs
        op_def = op_dict[node.op]
KeyError: 'RegexReplace'

任何建议可能出现的问题?

0 个答案:

没有答案