TensorFlow Graph Editor.
The TensorFlow Graph Editor library allows for modification of an existing tf.Graph instance in-place.
The author's github username is purpledog.
Appending new nodes is the only graph editing operation allowed by the TensorFlow core library. The Graph Editor library is an attempt to allow for other kinds of editing operations, namely, rerouting and transforming.
Important: modifying a graph in-place with the Graph Editor must be done offline, that is, without any active sessions.
Of course new operations can be appended online but Graph Editor specific operations like rerouting and transforming can currently only be done offline.
Here is an example of what you cannot do:
same previously created session.To edit an already running graph, follow these steps:
Note that this procedure is very costly because a new session must be created after any modifications. Among other things, it takes time because the entire graph state must be saved and restored again.
Most of the functions in the Graph Editor library operate on sub-graph. More precisely, they take as input arguments instances of the SubGraphView class (or anything which can be converted to it). Doing so allows the same function to transparently operate on single operations as well as sub-graph of any size.
A subgraph can be created in several ways:
my_sgv = ge.sgv(ops)
my_sgv = ge.sgv_scope("foo/bar", graph=tf.get_default_graph())
my_sgv = ge.sgv("foo/.*/.*read$", graph=tf.get_default_graph())
Note that the Graph Editor is meant to manipulate several graphs at the same time, typically during transform or copy operation. For that reason, to avoid any confusion, the default graph is never used and the graph on which to operate must always be given explicitly. This is the reason why graph=tf.get_default_graph() is used in the code snippets above.
tf.Graph.tf.contrib.graph_editor.make_list_of_optf.contrib.graph_editor.get_tensorstf.contrib.graph_editor.make_list_of_ttf.contrib.graph_editor.get_generating_opstf.contrib.graph_editor.get_consuming_opstf.contrib.graph_editor.ControlOutputstf.contrib.graph_editor.placeholder_nametf.contrib.graph_editor.make_placeholder_from_tensortf.contrib.graph_editor.make_placeholder_from_dtype_and_shapetf.contrib.graph_editor.filter_tstf.contrib.graph_editor.filter_ts_from_regextf.contrib.graph_editor.filter_opstf.contrib.graph_editor.filter_ops_from_regextf.contrib.graph_editor.get_name_scope_opstf.contrib.graph_editor.check_ciostf.contrib.graph_editor.get_ops_iostf.contrib.graph_editor.compute_boundary_tstf.contrib.graph_editor.get_within_boundary_opstf.contrib.graph_editor.get_forward_walk_opstf.contrib.graph_editor.get_backward_walk_opstf.contrib.graph_editor.get_walks_intersection_opstf.contrib.graph_editor.get_walks_union_opstf.contrib.graph_editor.select_opstf.contrib.graph_editor.select_tstf.contrib.graph_editor.select_ops_and_tstf.contrib.graph_editor.SubGraphViewtf.contrib.graph_editor.make_viewtf.contrib.graph_editor.make_view_from_scopetf.contrib.graph_editor.swap_tstf.contrib.graph_editor.reroute_tstf.contrib.graph_editor.swap_inputstf.contrib.graph_editor.reroute_inputstf.contrib.graph_editor.swap_outputstf.contrib.graph_editor.reroute_outputstf.contrib.graph_editor.swap_iostf.contrib.graph_editor.reroute_iostf.contrib.graph_editor.remove_control_inputstf.contrib.graph_editor.add_control_inputstf.contrib.graph_editor.detach_control_inputstf.contrib.graph_editor.detach_control_outputstf.contrib.graph_editor.detach_inputstf.contrib.graph_editor.detach_outputstf.contrib.graph_editor.detachtf.contrib.graph_editor.connecttf.contrib.graph_editor.bypasstf.contrib.graph_editor.replace_t_with_placeholder_handlertf.contrib.graph_editor.keep_t_if_possible_handlertf.contrib.graph_editor.assign_renamed_collections_handlertf.contrib.graph_editor.transform_op_if_inside_handlertf.contrib.graph_editor.copy_op_handlertf.contrib.graph_editor.Transformertf.contrib.graph_editor.copytf.contrib.graph_editor.copy_with_input_replacementstf.contrib.graph_editor.graph_replace
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_guides/python/contrib.graph_editor