【发布时间】:2017-10-10 01:46:34
【问题描述】:
在 Python 中,我有一个冻结的 graph.pb,我目前正在 C++ 环境中使用它。现在输入张量的数据当前在 CPU 上进行了预处理,但我想在另一个 GraphDef 中执行此步骤以在 GPU 上运行它,但我似乎找不到连接两个 GraphDef 之间节点的方法的。
假设我的冻结图有一个名为 mid 的输入/占位符,我想将其与下面的预处理步骤联系起来
tf::GraphDef create_graph_extension() {
tf::Scope root = tf::Scope::NewRootScope();
auto a = tf::ops::Const(root.WithOpName("in"), {(float) 23.0, (float) 31.0});
auto b = tf::ops::Identity(root.WithOpName("mid"), a);
tf::GraphDef graph;
TF_CHECK_OK(root.ToGraphDef(&graph));
return graph;
}
我通常使用session->Extend() 在同一个会话中运行多个图表,但始终确保它们的节点名称是唯一的。对于我希望连接的非唯一节点名称,我收到错误
Failed to install graph:
Invalid argument: GraphDef argument to Extend includes node 'mid', which
was created by a previous call to Create or Extend in this session.
附:似乎至少在 python 中是可能的 (link)
【问题讨论】:
标签: c++ tensorflow