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?
Asked
Active
Viewed 2,807 times
10

Tomi
- 391
- 1
- 3
- 8
1 Answers
14
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.

mrry
- 125,488
- 26
- 399
- 400
-
I wish `tensorflow::Session` was documented :( – Sdra Nov 09 '17 at 15:36
-
There's quite a lot of documentation in the [code](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/public/session.h). Feel free to open a GitHub [issue](https://github.com/tensorflow/tensorflow/issues) or propose a change in a [pull request](https://github.com/tensorflow/tensorflow/pulls) if there are details you'd like to see added! – mrry Nov 09 '17 at 20:58