3

I'm looking to run a basic fully-connected neural network for the MNIST dataset with the C++ API v1.2 from Tensorflow. I have trained the model and exported it using tf.train.Saver() in Python. This gave me a checkpoint file, a data file, an index file and a meta file.

I know that the data file contains the saved variables while the meta file contains the graph from using Tensorboard on a previous project.

However, I am not sure what is the recommended way to load those files and run the trained model in a C++ environment in v1.2, since all the tutorials and questions I've found are for older versions which differ substantially.

I've found that tensorflow::ops::Restore should be the method to do such a thing, but I know that inference in Tensorflow isn't well supported, as such I am not certain what parameters should I give it in order to receive the trained model that I can just put into a session->Run() and receive an accuracy statement when fed test data.

Stefan Roman
  • 71
  • 1
  • 7
  • Possible duplicate of [Tensorflow Different ways to Export and Run graph in C++](https://stackoverflow.com/questions/35508866/tensorflow-different-ways-to-export-and-run-graph-in-c) – P-Gn Jul 10 '17 at 12:25
  • 1
    Have a look in particular at this answer: https://stackoverflow.com/a/43639305/1735003 – P-Gn Jul 10 '17 at 12:26
  • 1
    Thank you for pointing it out, however, as I've stated in my question, I'm using v1.2 which differs greatly in how sessions are run and many old methods are now unavailable/only for internal use in the code/deprecated. – Stefan Roman Jul 11 '17 at 08:36
  • I am using 1.2.1 and I still find the above post relevant. Which part of the C++ code is broken for you? – P-Gn Jul 11 '17 at 08:51
  • As far as I can see, ClientSession is the only provided way to run sessions and it only has one method, Run(). I don't see a way to access the Session class so I can use Create() or other methods. – Stefan Roman Jul 11 '17 at 09:35
  • In the answer I linked above, they call `NewSession` which returns a `Session*`. – P-Gn Jul 11 '17 at 09:40
  • 1
    I've found the problem. It seems that in my confusion with how bazel works, I forgot to add includes, now it's all good. Thank you! – Stefan Roman Jul 11 '17 at 10:47

0 Answers0