Often you want to hook into an existing model. Here are some tricks for finding tensors that you care about
target_node = graph.get_tensor_by_name("predictions:0")
target_node.op.inputs
target_node = graph.get_tensor_by_name("predictions:0")
[output for op in target_node.consumers() for output in op.outputs]
target_shape = (None, 32, 32, 3)
def shape_tuple(tensor):
return tuple(map(lambda i: i.value, tensor.get_shape()))
tensors = tf.contrib.graph_editor.get_tensors(graph)
[t for t in tensors if shape_tuple(t) == target_shape]
target_name = 'logit'
tensors = tf.contrib.graph_editor.get_tensors(graph)
[t for t in tensors if target_name in t.name]