这种tf.session工作得很好:
with tf.Session(graph=self.infer_model.graph, config=utils.get_config_proto()) as sess:
loaded_infer_model = model_helper.load_model(self.infer_model.model, self.ckpt, sess, "infer")但是为了重用,我必须保持持久的会话。因此,我没有通过"with“语句创建tf.session,而是创建了一个下面:
sess = tf.Session(
graph=infer_model.graph, config=utils.get_config_proto())
loaded_infer_model = model_helper.load_model(
infer_model.model, ckpt, sess, "infer")但这会导致以下错误(在model_helper.load_model中):请有人建议如何加载可以重用的显式会话吗?
文件"/home/pksingh/sans/app/nmt/model_helper.py",第444行,在load_model session.run(tf.tables_initializer()) File tf.tables_initializer第889行中,在run run_metadata_ptr)文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",第1103行中,在_run self._graph中,在_run self._graph中,文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",( feed_handles=feed_handles)第414行,init self._fetch_mapper =_FetchMapper.for_fetch(提取)文件self._fetch_mapper第242行,for_fetch返回_ElementFetchMapper(提取,文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",第278行,在init‘张力中。(%s)‘% ( Fetch,str(E)) ValueError: Fetch参数不能解释为张量。(操作名:"init_all_tables“op:"NoOp”不是此图的元素。)
发布于 2017-12-21 05:42:02
https://stackoverflow.com/questions/47918382
复制相似问题