Exemplo n.º 1
0
        private static FlowGraph LoadGraph(GraphProto graph)
        {
            var nodes      = new Dictionary <string, Layer>();
            var typeDic    = new Dictionary <string, TensorType>();
            var outputConn = new Dictionary <string, OutputConnector>();

            foreach (var init in graph.Initializer)
            {
                nodes.Add(init.Name, ParseConstantNode(init, typeDic, outputConn));
            }

            foreach (var input in graph.Input.Where(o => !nodes.ContainsKey(o.Name)))
            {
                nodes.Add(input.Name, ParseInputVariableNode(input, typeDic, outputConn));
            }

            foreach (var node in graph.Node)
            {
                nodes.Add(node.Name, ParseNode(node, typeDic, outputConn));
            }
            return(FlowGraph.From(outputConn[graph.Output[0].Name]));
        }