显式 tensorflow 会话在 Tensorflow/nmt 中出现获取错误
Explicit tensorflow session gives fetch error in Tensorflow/nmt
这种 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,而是创建了一个 under:
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 中):有人可以建议如何加载可以重复使用的显式会话吗?
File "/home/pksingh/sans/app/nmt/model_helper.py", line 444, in
load_model session.run(tf.tables_initializer()) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 889, in run run_metadata_ptr) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 1103, in _run self._graph, fetches, feed_dict_tensor,
feed_handles=feed_handles) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 414, in init self._fetch_mapper = _FetchMapper.for_fetch(fetches)
File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 242, in for_fetch return _ElementFetchMapper(fetches,
contraction_fn) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 278, in init 'Tensor. (%s)' % (fetch, str(e))) ValueError: Fetch
argument cannot be
interpreted as a Tensor. (Operation name: "init_all_tables" op: "NoOp"
is not an element of this graph.)
实现相同目标的最佳选择是使用交互式会话。您可以像这样初始化交互式会话:
sess = tf.InteractiveSession()
访问此 link 了解更多详情。
这种 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,而是创建了一个 under:
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 中):有人可以建议如何加载可以重复使用的显式会话吗?
File "/home/pksingh/sans/app/nmt/model_helper.py", line 444, in load_model session.run(tf.tables_initializer()) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1103, in _run self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 414, in init self._fetch_mapper = _FetchMapper.for_fetch(fetches) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 242, in for_fetch return _ElementFetchMapper(fetches, contraction_fn) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 278, in init 'Tensor. (%s)' % (fetch, str(e))) ValueError: Fetch argument cannot be interpreted as a Tensor. (Operation name: "init_all_tables" op: "NoOp" is not an element of this graph.)
实现相同目标的最佳选择是使用交互式会话。您可以像这样初始化交互式会话:
sess = tf.InteractiveSession()
访问此 link 了解更多详情。