在c+中创建图形+;从包含新op的python中创建的pb图形 如何将我的LBTySoFr.Oracle C.So库与我的自定义OP链接,这样我就可以在C++中进行训练?我的自定义操作是用C++编写的,使用它的图形是用Python计算的。我可以加载pb图形,但无法创建图形

在c+中创建图形+;从包含新op的python中创建的pb图形 如何将我的LBTySoFr.Oracle C.So库与我的自定义OP链接,这样我就可以在C++中进行训练?我的自定义操作是用C++编写的,使用它的图形是用Python计算的。我可以加载pb图形,但无法创建图形,python,c++,tensorflow,Python,C++,Tensorflow,我用python创建了一个图形,并用write_graph保存为protobuf文件。我的图形使用一个自定义的OP,其内核是用C++编写的,并注册为IN。我想把C++中的图表装入训练中,图形没有警告就加载了,但是对于“session ->创建(GraceDeF)”,我会得到一个错误: Non-OK-status: session->Create(graph_def) status: Not found: Op type not registered 'MyOp' in binary ru

我用python创建了一个图形,并用write_graph保存为protobuf文件。我的图形使用一个自定义的OP,其内核是用C++编写的,并注册为IN。我想把C++中的图表装入训练中,图形没有警告就加载了,但是对于“session ->创建(GraceDeF)”,我会得到一个错误:

Non-OK-status: session->Create(graph_def) status: Not found: 
Op type not registered 'MyOp' in binary running on user-linux. 
Make sure the Op and Kernel are registered in the binary running in this process. 
Note that if you are loading a saved graph which used ops from tf.contrib,
accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph,
as contrib ops are lazily registered when the module is first accessed.
我没有使用tf.contrib的任何东西。这是我的C++代码的一个更简单的版本:

    std::string graph_definition = "Mygraph.pb";
    Session* session; 
    GraphDef graph_def;
    SessionOptions opts;


    //load graph 
    TF_CHECK_OK(ReadBinaryProto(Env::Default(), graph_definition, &graph_def));
    // create a new session
    TF_CHECK_OK(NewSession(opts, &session));
    // Load graph into session
    TF_CHECK_OK(session->Create(graph_def)); 

似乎需要使用中定义的
TF\u LoadLibrary
加载库。在本文中,您有一个示例说明了它的工作原理:

// Load the library.
TF_Status* status = TF_NewStatus();
TF_Library* lib =
    TF_LoadLibrary("tensorflow/c/test_op.so", status);
TF_Code code = TF_GetCode(status);
string status_msg(TF_Message(status));
TF_DeleteStatus(status);
ASSERT_EQ(TF_OK, code) << status_msg;
//加载库。
TF_Status*Status=TF_NewStatus();
TF_库*lib=
TF_LoadLibrary(“tensorflow/c/test_op.so”,状态);
TF_代码=TF_GetCode(状态);
字符串状态消息(TF消息(状态));
TF_删除状态(状态);

ASSERT_EQ(TF_OK,code)我通过在c+代码中包含my_op.cc头文件解决了我的问题。警告正在查找注册表(我的注册表)标签。我认为,在C++中,用jjDESa提出的方法是必要的,但是如果我只想运行以前在Python中计算的图形,不是吗?@ CeScCueld,有趣的是,我假设在任何情况下,库加载函数的注册都是必要的。但是,如果只是在声明中包含标题,那么肯定会简单得多。