def collect_tf_references(model_path, feed_dict, out_layer, output_nodes_for_freeze=None):
    _feed_dict = dict()
    graph = load_graph(model_path, output_nodes_for_freeze)
    output_tensors_list = list()
    outputs_list = list()
    for input in feed_dict:
        input_node = [node for node in graph.as_graph_def().node if (node.name == input)][0]
        if (input_node.op == 'Placeholder'):
            tensor = graph.get_tensor_by_name((input + ':0'))
            _feed_dict[tensor] = feed_dict[input]
        else:
            for parrent_input in input_node.input:
                in_node = [node for node in graph.as_graph_def().node if (node.name == parrent_input)][0]
                if (in_node.op in ['Const', 'Assign', 'NoOp', 'Assert']):
                    continue
                else:
                    tensor = graph.get_tensor_by_name((parrent_input + ':0'))
                _feed_dict[tensor] = feed_dict[input]
    for output in out_layer:
        tensor = graph.get_tensor_by_name((output + ':0'))
        output_tensors_list.append(tensor)
        outputs_list.append(output)
    with graph.as_default():
        with tf.compat.v1.Session(graph=graph) as sess:
            outputs = sess.run(output_tensors_list, feed_dict=_feed_dict)
    out_dict = dict(zip(outputs_list, outputs))
    return out_dict
def collect_tf_references(model_path, feed_dict, out_layer, output_nodes_for_freeze=None):
    _feed_dict = dict()
    graph = load_graph(model_path, output_nodes_for_freeze)
    output_tensors_list = list()
    outputs_list = list()
    for input in feed_dict:
        input_node = [node for node in graph.as_graph_def().node if (node.name == input)][0]
        if (input_node.op == 'Placeholder'):
            tensor = graph.get_tensor_by_name((input + ':0'))
            _feed_dict[tensor] = feed_dict[input]
        else:
            for parrent_input in input_node.input:
                in_node = [node for node in graph.as_graph_def().node if (node.name == parrent_input)][0]
                if (in_node.op in ['Const', 'Assign', 'NoOp', 'Assert']):
                    continue
                else:
                    tensor = graph.get_tensor_by_name((parrent_input + ':0'))
                _feed_dict[tensor] = feed_dict[input]
    for output in out_layer:
        tensor = graph.get_tensor_by_name((output + ':0'))
        output_tensors_list.append(tensor)
        outputs_list.append(output)
    with graph.as_default():
        with tf.compat.v1.Session(graph=graph) as sess:
            outputs = sess.run(output_tensors_list, feed_dict=_feed_dict)
    out_dict = dict(zip(outputs_list, outputs))
    return out_dict