Some models have non-descriptive input- and output node names. The user should have the ability to give model inputs and -outputs to more descriptive designations.
Scope
Renaming nodes should only be done using the API. CLI support can be added later.
The util module should be extended to include a new functions rename_nodesrename_input_nodes and rename_output_nodes.
Renaming graph nodes is reserved to the util module and not exposed to any api function or CLI option.
Signatures are more interesting targets for renaming as keys can map to different tensors (nodes) and renaming doesn't
affect the graph.
Details
util.rename_nodes takes a tf.GraphGraphDef proto and a simple dict which maps exiting node names to new nodes as arguments. The function should return a copy of the input graph with the new names applied. Non-existing nodes should raise a ValueError.
The rename functionality should only be applicable to input- and output nodes. Specifying any other node, regardless of whether it's a valid node in the graph, will result in a ValueError.
All API functions that load or convert graphs should get new optional keyword arguments input_map and output_map, which are dicts that map model node names to new names (using util.rename_nodes).
Output node names selected for TF SavedModel outputs should accept both original, and renamed outputs.
Renaming via api (not util!) functions should only affect signatures and only be applicable to the SavedModel format.
Selected SavedModel outputs must refer to the original output name, since the user might swap input names, which would make it impossible to make the correct choice if any of new or old would be allowed
CLI Options
--map_input and --map_output --rename options could be introduced
only valid if the output format tf_saved_model is selected
format could be old_name:new_name
accept comma-separated entries, e.g. old1:new1,old2:new2 to stay consistent with the format of other options that accept multiple values: specifying an option multiple times is cumbersome IMO and specifying multiple args using spaces can be confusing, since we also use positional arguments
Description
Some models have non-descriptive input- and output node names. The user should have the ability to give model inputs and -outputs to more descriptive designations.
Scope
anew functionsrename_nodes
rename_input_nodes
andrename_output_nodes
.util
module and not exposed to anyapi
function or CLI option.Details
util.rename_nodes
takes atf.Graph
GraphDef
proto and a simpledict
which maps exiting node names to new nodes as arguments. The function should return a copy of the input graph with the new names applied. Non-existing nodes should raise aValueError
.ValueError
.All API functions that load or convert graphs should get new optional keyword arguments input_map and output_map, which aredict
s that map model node names to new names (usingutil.rename_nodes
).Output node names selected for TF SavedModel outputs should accept both original, and renamed outputs.api
(notutil
!) functions should only affect signatures and only be applicable to the SavedModel format.CLI Options
--rename option--map_input
and--map_output
scould be introduced