在Tensorflow中,用C++获得图中所有张量的名称。 使用C++加载A.PB模型后, 如何使用TunSoFraseCub使用C++来添加名称值。
.pb文件中的图层如下所示:在Tensorflow中,用C++获得图中所有张量的名称。 使用C++加载A.PB模型后, 如何使用TunSoFraseCub使用C++来添加名称值。,c++,c++11,tensorflow,C++,C++11,Tensorflow,.pb文件中的图层如下所示: node { name: "add" op: "Add" input: "MatMul" input: "bias/read" attr { key: "T" value { type: DT_FLOAT } } } node { name: "output_TT" op: "Softmax" input: "add" attr { key: "T" value {
node {
name: "add"
op: "Add"
input: "MatMul"
input: "bias/read"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}
node {
name: "output_TT"
op: "Softmax"
input: "add"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}
我不是用bazel来建造;相反,我执行了带有一些定制的inbuild makefile。我通过以下步骤获得了输出
int node_count = graph_def.node_size();
for (int i = 0; i < node_count; i++)
{
auto n = graph_def.node(i);
cout<<"Names : "<< n.name() <<endl;
}
我通过以下步骤得到了输出
int node_count = graph_def.node_size();
for (int i = 0; i < node_count; i++)
{
auto n = graph_def.node(i);
cout<<"Names : "<< n.name() <<endl;
}
在下面的代码中,vNames变量将包含层名称
int node_count = graph_def.node_size();
std::vector<string> vNames;
for (int i = 0; i < node_count; i++)
{
auto n = graph_def.node(i);
if ((has_suffix(n.name(), "/read")) || (has_suffix(n.name(), "_w")) || (has_suffix(n.name(), "_b")))
{
vNames.push_back(n.name());
}
}
在下面的代码中,vNames变量将包含层名称
int node_count = graph_def.node_size();
std::vector<string> vNames;
for (int i = 0; i < node_count; i++)
{
auto n = graph_def.node(i);
if ((has_suffix(n.name(), "/read")) || (has_suffix(n.name(), "_w")) || (has_suffix(n.name(), "_b")))
{
vNames.push_back(n.name());
}
}