TensorFlow r1.0 C++ API comes with Session
and ClientSession
classes. Some of the examples shipping with TensorFlow use ClientSession
and others use Session
. Do these two different types of session use the same underlying mechanism under the hood or is one of the preferred over another? The syntax for using them is a bit different but other than that are there any differences in behavior?
A session allows to execute graphs or part of graphs. It allocates resources (on one or more machines) for that and holds the actual values of intermediate results and variables.
Tensorflow is built using C++ and it offers an API to make it relatively easier to deploy models (and even train models if you wish to) in C++.
If you write a C++ program utilizing TensorFlow, it Will (providing you know how to program) be magnitudes faster than a Python equivalent.
In TensorFlow's C++ API, the tensorflow::Session
API is a low-level interface that deals with serialized GraphDef
protocol buffers and provides a string-based interface for running subgraphs.
By contrast, the tensorflow::ClientSession
API is higher level, and integrates with the new C++ API for building TensorFlow graphs—much in the same way as the Python tf.Graph
and tf.Session
classes do.
Therefore, you will probably want to use a tensorflow::ClientSession
if you are building the graph with the C++ API, but the tensorflow::Session
interface is easier to use if you already have a serialized GraphDef
(representing e.g. a pre-trained model) and just want to run inference on that model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With