parameters: (graph_def, target_node_name, shape)
return_statement: return replaced_graph_def
docstring: Replace original input node as placeholder. Freezing graph will include some
    nodes of tf.data. eg "IteratorGetNext". This function remove these nodes and
    replace them with placeholder node.
    Args:
      input_graph_def: the graph_def to be replaced
      target_node_name: the specified node to be replaced
    Returns:
      Replaced GraphDef
docstring_summary: Replace original input node as placeholder. Freezing graph will include some
    nodes of tf.data. eg "IteratorGetNext". This function remove these nodes and
    replace them with placeholder node.
    Args:
      input_graph_def: the graph_def to be replaced
      target_node_name: the specified node to be replaced
    Returns:
      Replaced GraphDef
docstring_tokens: Replace original input node as placeholder . Freezing graph will include some nodes of tf . data . eg IteratorGetNext . This function remove these nodes and replace them with placeholder node . Args : input_graph_def : the graph_def to be replaced target_node_name : the specified node to be replaced Returns : Replaced GraphDef
function: def SetInputNodesAsPlaceholder(graph_def, target_node_name, shape):
    """
    Replace original input node as placeholder. Freezing graph will include some
    nodes of tf.data. eg "IteratorGetNext". This function remove these nodes and
    replace them with placeholder node.
    Args:
      input_graph_def: the graph_def to be replaced
      target_node_name: the specified node to be replaced
    Returns:
      Replaced GraphDef
    """
    shape[0] = None if shape[0] == -1 else shape[0]
    name_to_node = {}
    for node in graph_def.node:
      name_to_node[node.name] = node
    if name_to_node[target_node_name].op == "Placeholder":
      return graph_def
    remove_nodes = _get_removed_nodes(name_to_node, target_node_name)
    placeholder = array_ops.placeholder(dtypes.float32, shape=shape, name=target_node_name)
    placeholder_def = placeholder.op.node_def
    placeholder_def.name = target_node_name
    replaced_graph_def = graph_pb2.GraphDef()
    replaced_graph_def.node.extend([placeholder_def])
    for node in graph_def.node:
      if node.name in remove_nodes:
        print("INFO: remove node:", node.name)
        continue
      if node.input and node.input[0] == target_node_name:
        print("INFO: re-map input node to ", node.name)
        new_node = copy.deepcopy(node)
        new_node.input[0] = placeholder_def.name
        replaced_graph_def.node.extend([new_node])
      else:
        replaced_graph_def.node.extend([copy.deepcopy(node)])
    return replaced_graph_def
function_tokens: def SetInputNodesAsPlaceholder ( graph_def , target_node_name , shape ) : shape [ 0 ] = None if shape [ 0 ] == - 1 else shape [ 0 ] name_to_node = { } for node in graph_def . node : name_to_node [ node . name ] = node if name_to_node [ target_node_name ] . op == "Placeholder" : return graph_def remove_nodes = _get_removed_nodes ( name_to_node , target_node_name ) placeholder = array_ops . placeholder ( dtypes . float32 , shape = shape , name = target_node_name ) placeholder_def = placeholder . op . node_def placeholder_def . name = target_node_name replaced_graph_def = graph_pb2 . GraphDef ( ) replaced_graph_def . node . extend ( [ placeholder_def ] ) for node in graph_def . node : if node . name in remove_nodes : print ( "INFO: remove node:" , node . name ) continue if node . input and node . input [ 0 ] == target_node_name : print ( "INFO: re-map input node to " , node . name ) new_node = copy . deepcopy ( node ) new_node . input [ 0 ] = placeholder_def . name replaced_graph_def . node . extend ( [ new_node ] ) else : replaced_graph_def . node . extend ( [ copy . deepcopy ( node ) ] ) return replaced_graph_def