Closed jmcs100 closed 5 years ago
The problem is that your graphs have None
s fields in them, so you cannot directly create the feed_dict like that.
Instead you should use the helper function gn.utils_tf.get_feed_dict
:
feed_dict = gn.utils_tf.get_feed_dict(
train_input_ph,
gn.utils_np.networkxs_to_graphs_tuple(train_input))
feed_dict.update(gn.utils_tf.get_feed_dict(
train_target_ph,
gn.utils_np.networkxs_to_graphs_tuple(train_target)))
Hope this works!
Hi,
I think you have Nones in your input. Can you try:
from graph_nets import utils_tf
feed_dict=utils_tf.get_feed_dict(train_input_ph: gn.utils_np.networkxs_to_graphs_tuple(train_input))
feed_dict.update(utils_tf.get_feed_dict(train_target_ph:gn.utils_np.networkxs_to_graphs_tuple(train_target))
Hi, thanks very much for getting back to me! So I'm now running:
for iteration in range(last_iteration, num_training_iterations):
last_iteration = iteration
feed_dict = utils_tf.get_feed_dict(
train_input_ph,
utils_np.networkxs_to_graphs_tuple(train_input))
feed_dict.update(utils_tf.get_feed_dict(
train_target_ph,
utils_np.networkxs_to_graphs_tuple(train_target)
))
train_values = sess.run({
"step": step_op,
"target": train_target_ph,
"train_loss": loss_train,
"outputs": output_train_graphs
},
feed_dict=feed_dict
)
And the error is now:
---------------------------------------------------------------------------
InternalError Traceback (most recent call last)
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1333 try:
-> 1334 return fn(*args)
1335 except errors.OpError as e:
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
1318 return self._call_tf_sessionrun(
-> 1319 options, feed_dict, fetch_list, target_list, run_metadata)
1320
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
1406 self._session, options, feed_dict, fetch_list, target_list,
-> 1407 run_metadata)
1408
InternalError: Unable to get element as bytes.
During handling of the above exception, another exception occurred:
InternalError Traceback (most recent call last)
<ipython-input-1140-2017fe71ea6b> in <module>
24 "outputs": output_train_graphs
25 },
---> 26 feed_dict=feed_dict
27 )
28 the_time = time.time()
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py 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)
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1150 if final_fetches or final_targets or (handle and feed_dict_tensor):
1151 results = self._do_run(handle, final_targets, final_fetches,
-> 1152 feed_dict_tensor, options, run_metadata)
1153 else:
1154 results = []
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1326 if handle is None:
1327 return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1328 run_metadata)
1329 else:
1330 return self._do_call(_prun_fn, handle, feeds, fetches)
/miniconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
1346 pass
1347 message = error_interpolation.interpolate(message, self._graph)
-> 1348 raise type(e)(node_def, op, message)
1349
1350 def _extend_graph(self):
InternalError: Unable to get element as bytes.
Googling this seems to suggest there can be all kinds of reasons for this error, so I thought I'd bring it back here just in case.
Can you try to see which output causes this?
For instance I think you wont be able to run train_target_ph
but should use utils_tf.make_runnable_in_session(train_target_ph)
I think you may need to use the graphs placeholders to call get_feed_dict before you pass them through by make_runnable_in_session
.
But you seem to be losing the reference to those when you do:
train_input_ph, train_target_ph, output_train_graphs, output_test_graphs = make_all_runnable_in_session(train_input_ph, train_target_ph, output_train_graphs, output_test_graphs)
Just try:
runnable_train_input_ph, runnable_train_target_ph, runnable_output_train_graphs, runnable_output_test_graphs = make_all_runnable_in_session(train_input_ph, train_target_ph, output_train_graphs, output_test_graphs)
And use the runnable_*
ones only for feeding them directly in the first argument of sess.run
, but not for anything else (not even to create the feed_dict).
Thanks so much! The model is now training, really appreciate the help
Hi! I'm trying to run a model that predicts node attributes based on global and edge inputs. I've been largely following the shortest_path.ipynb demo to write my code, and my code at the moment looks as follows (happy to include more if need be!):
In the running training section of code, I then have:
However, when I try to run the second set of code, I get the following error:
I notice this is a similar thing to #24 but when I tried the solution there of reducing make_all_runnable_in_session to only act on output_train_graphs and output_test_graphs, I get the following error instead:
What can I do with the feed_dict and session variables to make this all work?