A typical way to do this is to build (and train) your model using Python, save the GraphDef proto to a file using tf.train.write_graph() , and then write the application using JNI to call the C ++ TensorFlow API (see full example here ).
When you plot your graph in Python, you must take into account the names of the tensors that will represent (i) the input data to be classified, and (ii) the predicted output values. You can then complete the step by loading the value for (i) and selecting the value for (ii).
One of the last issues is how to present the model parameters in the exported graph. There are several ways to do this, including delivering a TensorFlow breakpoint (written by tf.train.Saver ) as part of your application and running ops recovery to restart it. One of the methods that was used in the released InceptionV3 model is to rewrite the graph so that the model parameters are replaced by "Const" nodes and the model graph becomes autonomous.
source share