离线下载
PDF版 ePub版

极客学院团队出品 · 更新于 2018-11-28 11:00:43

TensorFlow C++ Session API reference documentation

TensorFlow's public C++ API includes only the API for executing graphs, as of version 0.5. To control the execution of a graph from C++:

  1. Build the computation graph using the Python API.
  2. Use tf.train.write_graph() to write the graph to a file.
  3. Load the graph using the C++ Session API. For example:

    ```c++ // Reads a model graph definition from disk, and creates a session object you // can use to run it. Status LoadGraph(string graph_file_name, Session* session) { GraphDef graph_def; TF_RETURN_IF_ERROR( ReadBinaryProto(Env::Default(), graph_file_name, &graph_def)); TF_RETURN_IF_ERROR(NewSession(SessionOptions(), session)); TF_RETURN_IF_ERROR((session)->Create(graph_def)); return Status::OK(); }

  4. Run the graph with a call to session->Run()

Classes

Structs