In Tensorflow, is there a way to find all placeholder tensors that are required to evaluate a certain output tensor? That is, is there a function that will return all (placeholder) tensors that must be fed into feed_dict
when sess.run(output_tensor)
is called ?
Here's an example of what I'd like to do, in pseudocode:
import tensorflow as tf
a = tf.placeholder(dtype=tf.float32,shape=())
b = tf.placeholder(dtype=tf.float32,shape=())
c = tf.placeholder(dtype=tf.float32,shape=())
d = a + b
f = b + c
# This should return [a,b] or [a.name,b.name]
d_input_tensors = get_dependencies(d)
# This should return [b,c] or [b.name,c.name]
f_input_tensors = get_dependencies(f)
EDIT: To clarify, I am not (necessarily) looking for all of the placeholders in the graph, just the ones that are required for defining a particular output tensor. The desired placeholders are likely to be only a subset of all placeholders in the graph.