def summarize_graph(model_path, output_nodes_for_freeze=None, reshape_net=None):
    placeholders = dict()
    variables = list()
    outputs = list()
    graph = load_graph(model_path, output_nodes_for_freeze)
    unlikely_output_types = ['Const', 'Assign', 'NoOp', 'Placeholder', 'Assert', 'switch_t', 'switch_f']
    for node in graph.as_graph_def().node:
        if (node.op == 'Placeholder'):
            node_dict = dict()
            node_dict['type'] = tf.DType(node.attr['dtype'].type).name
            node_dict['shape'] = str(node.attr['shape'].shape.dim).replace('\n', '').replace(' ', '').replace('size:', '').replace('[', '').replace(']', '')
            node_dict['shape'] = tuple(map((lambda x: int(x)), node_dict['shape'].split(',')))
            placeholders[node.name] = node_dict
        if ((node.op == 'Variable') or (node.op == 'VariableV2')):
            variables.append(node.name)
        if (len(children(node.name, graph)) == 0):
            if ((node.op not in unlikely_output_types) and (node.name.split('/')[(- 1)] not in unlikely_output_types)):
                outputs.append(node.name)
    result = dict()
    result['inputs'] = placeholders
    result['outputs'] = outputs
    if reshape_net:
        out_layer = (list(result['inputs'].keys()) + result['outputs'])
        feed_dict = {}
        for inputl in reshape_net:
            feed_dict.update({inputl: np.ones(shape=reshape_net[inputl])})
        scoring_res = collect_tf_references(model_path=model_path, feed_dict=feed_dict, out_layer=out_layer)
        for layer in scoring_res:
            if (layer in result['inputs']):
                result['inputs'][layer]['shape'] = scoring_res[layer].shape
    return result
def summarize_graph(model_path, output_nodes_for_freeze=None, reshape_net=None):
    placeholders = dict()
    variables = list()
    outputs = list()
    graph = load_graph(model_path, output_nodes_for_freeze)
    unlikely_output_types = ['Const', 'Assign', 'NoOp', 'Placeholder', 'Assert', 'switch_t', 'switch_f']
    for node in graph.as_graph_def().node:
        if (node.op == 'Placeholder'):
            node_dict = dict()
            node_dict['type'] = tf.DType(node.attr['dtype'].type).name
            node_dict['shape'] = str(node.attr['shape'].shape.dim).replace('\n', ).replace(' ', ).replace('size:', ).replace('[', ).replace(']', )
            node_dict['shape'] = tuple(map((lambda x: int(x)), node_dict['shape'].split(',')))
            placeholders[node.name] = node_dict
        if ((node.op == 'Variable') or (node.op == 'VariableV2')):
            variables.append(node.name)
        if (len(children(node.name, graph)) == 0):
            if ((node.op not in unlikely_output_types) and (node.name.split('/')[(- 1)] not in unlikely_output_types)):
                outputs.append(node.name)
    result = dict()
    result['inputs'] = placeholders
    result['outputs'] = outputs
    if reshape_net:
        out_layer = (list(result['inputs'].keys()) + result['outputs'])
        feed_dict = {}
        for inputl in reshape_net:
            feed_dict.update({inputl: np.ones(shape=reshape_net[inputl])})
        scoring_res = collect_tf_references(model_path=model_path, feed_dict=feed_dict, out_layer=out_layer)
        for layer in scoring_res:
            if (layer in result['inputs']):
                result['inputs'][layer]['shape'] = scoring_res[layer].shape
    return result