Nmt: Explicit session gives fetch error

Created on 20 Dec 2017  路  1Comment  路  Source: tensorflow/nmt

Hi,

I have to keep persistent session for serving. So instead of creating tf.session by "with" statement, I created a 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")

But this gives following error (in model_helper.load_model ): Can someone please suggest for how to load explicit session which can be reused?

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.)

Most helpful comment

Hi Jolly,
I guess you probably have found the answer. To make it work, you need to do:

 with infer_model.graph.as_default():
    loaded_infer_model = model_helper.load_model(
        infer_model.model, ckpt_path, sess, "infer")

-Thang

>All comments

Hi Jolly,
I guess you probably have found the answer. To make it work, you need to do:

 with infer_model.graph.as_default():
    loaded_infer_model = model_helper.load_model(
        infer_model.model, ckpt_path, sess, "infer")

-Thang

Was this page helpful?
0 / 5 - 0 ratings