Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Keras model to C++ [closed]

I am using Keras (with Theano) to train my CNN model. Does anyone has idea how can I use it in my C++ application? Does anyone tried something similar? I have idea to write some python code that will generate a c++ code with network functions - any suggestion on it?

I found a similar question here how to use Tensorflow Keras model in C++ but without answer.

like image 378
pplonski Avatar asked Apr 19 '16 13:04

pplonski


1 Answers

To answer my own question and have a solution - I wrote a plain c++ solution called keras2cpp (its code available on github).

In this solution you store network architecture (in json) and weights (in hdf5). Then you can dump a network to a plain text file with provided script. You can use obtained text file with network in pure c++ code. There are no dependencies on python libraries or hdf5. It should work for theano and tensorflow backend.

like image 152
pplonski Avatar answered Oct 03 '22 06:10

pplonski