C++ equivalent of python: tf.Graph.get_tensor_by_name() in Tensorflow?

后端 未结 3 1234
滥情空心
滥情空心 2020-12-18 07:23

What is the C++ equivalent of python: tf.Graph.get_tensor_by_name(name) in Tensorflow? Thanks!

Here is the code I am trying to run, but I get an empty output

3条回答
  •  孤城傲影
    2020-12-18 08:06

    there is a way to get neural node from graph_def directly. if u only want the shape\type of node: "some_name":

    void readPB(GraphDef & graph_def)
    {
    
        int i;
        for (i = 0; i < graph_def.node_size(); i++)
        {
            if (graph_def.node(i).name() == "inputx")
            {
                graph_def.node(i).PrintDebugString();
            }
        }
    }
    

    results:

    name: "inputx"
    op: "Placeholder"
    attr {
      key: "dtype"
      value {
        type: DT_FLOAT
      }
    }
    attr {
      key: "shape"
      value {
        shape {
          dim {
            size: -1
          }
          dim {
            size: 5120
          }
        }
      }
    }
    

    try member functins of the node and get the informations.

提交回复
热议问题