Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None Types and Operations in feed_dict #24

Closed
dmclark17 opened this issue Nov 20, 2018 · 2 comments
Closed

None Types and Operations in feed_dict #24

dmclark17 opened this issue Nov 20, 2018 · 2 comments

Comments

@dmclark17
Copy link

Hello,

I am attempting to use the InteractionNetwork with no global attributes. As mentioned in #22, I have set global_model_fn=None for the GraphIndependent block for encoding and decoding. My input placeholder graph tuple looks like this

GraphsTuple(
nodes=<tf.Tensor 'input_graph_placeholder/nodes:0' shape=(?, 6) dtype=float64>, 
edges=<tf.Tensor 'input_graph_placeholder/edges:0' shape=(?, 2) dtype=float64>,
receivers=<tf.Tensor 'input_graph_placeholder/receivers:0' shape=(?,) dtype=int32>, 
senders=<tf.Tensor 'input_graph_placeholder/senders:0' shape=(?,) dtype=int32>, 
globals=None, 
n_node=<tf.Tensor 'input_graph_placeholder/n_node:0' shape=(?,) dtype=int32>, 
n_edge=<tf.Tensor 'input_graph_placeholder/n_edge:0' shape=(?,) dtype=int32>
)

As expected globals = None, I then use the make_all_runnable_in_session as defined in the demos. This yields

GraphsTuple(
nodes=<tf.Tensor 'input_graph_placeholder/nodes:0' shape=(?, 6) dtype=float64>,
edges=<tf.Tensor 'input_graph_placeholder/edges:0' shape=(?, 2) dtype=float64>, 
receivers=<tf.Tensor 'input_graph_placeholder/receivers:0' shape=(?,) dtype=int32>,
senders=<tf.Tensor 'input_graph_placeholder/senders:0' shape=(?,) dtype=int32>, 
globals=<tf.Operation 'make_graph_runnable_in_session/NoOp' type=NoOp>,
n_node=<tf.Tensor 'input_graph_placeholder/n_node:0' shape=(?,) dtype=int32>, 
n_edge=<tf.Tensor 'input_graph_placeholder/n_edge:0' shape=(?,) dtype=int32>
)

As expected, this converts the None into a Tensorflow no_op. But when I try to run the session, I run into this error

TypeError                                 Traceback (most recent call last)
<ipython-input-6-ca8c0124fd42> in <module>()
     21       "loss": loss_op_tr,
     22       "outputs": output_ops_tr
---> 23   }, feed_dict=feed_dict)
     24 
     25 

/home/david/.local/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata)
    927     try:
    928       result = self._run(None, fetches, feed_dict, options_ptr,
--> 929                          run_metadata_ptr)
    930       if run_metadata:
    931         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/home/david/.local/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1093           except Exception as e:
   1094             raise TypeError(
-> 1095                 'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
   1096 
   1097           if isinstance(subfeed_val, ops.Tensor):

TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a Operation into a Tensor.

The TensorFlow documentation seems to indicate Operations cannot be keys of feed_dict. Is this how None types are suppose to be handled?

I am running Tensorflow version 1.12.0 with python 2.7 on Ubuntu 18.04

Thank you!

@vbapst
Copy link

vbapst commented Nov 20, 2018

Hi David,

make_all_runnable_in_session is meant to be used for the output of the graph, to convert GraphsTuple containing possibly None fields into runnable tensors.
In your case, you should do
feed_dict = utils_tf.get_feed_dict(placeholders, input_graph)
where placeholders is the GraphsTuple you correctly constructed in your first snippet.

@dmclark17
Copy link
Author

Great! Thank you!

I am now running:

  • make_all_runnable_in_session on output_ops_tr and output_ops_tr
  • utils_tf.get_feed_dict(placeholders, input_graph) on my inputs and targets

And it is working for None fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants