2

Using TensorFlow, I'm trying to load a network in a C++ file, that I trained in Python. I'm saving a network with input tensor x and output tensor y on Python with:

with tf.Session(graph=tf.Graph()) as sess:
        tf.saved_model.simple_save(sess, export_dir, inputs={"ob": x}, outputs={"out": y})

Then, following these examples, I'm doing this in my C file:

TF_Buffer* buffer = ReadBufferFromFile("graph.pb");
TF_Graph* graph = TF_NewGraph();
TF_Status* status = TF_NewStatus();
TF_ImportGraphDefOptions* opts = TF_NewImportGraphDefOptions();

TF_GraphImportGraphDef(graph, buffer, opts, status);

But I'm getting a TF_Status error code TF_INVALID_ARGUMENT when doing the TF_GraphImportGraphDef call. The buffer is being loaded, I can print its length and get a value (192 in this case).

What should I do, or how can I do this? Using Bazel and the C++ API is not an option.

BlueMoon93
  • 2,910
  • 22
  • 39
  • Has this been tried in tensorflow 2.0? – jregalad Sep 19 '19 at 14:43
  • @jregalad Nope, it has not – BlueMoon93 Sep 19 '19 at 14:49
  • I get it to work with TF_LoadSessionFromSavedModel and model can be trained saving weights to a checkpoint file. But I just can;t get to reload said checkpoints into python again. It's driving me mad https://stackoverflow.com/questions/57993832/load-weights-from-checkpoint-not-working-in-keras-model – jregalad Sep 19 '19 at 14:58

0 Answers0