Counting 1,477 Big Data & Machine Learning Frameworks, Toolsets, and Examples...
Suggestion? Feedback? Tweet @stkim1

Last Commit
May. 22, 2017
May. 2, 2016


This is a bunch of code to port Keras neural network model into pure C++. Neural network weights and architecture are stored in plain text file and input is presented as vector<vector<vector<float> > > in case of image. The code is prepared to support simple Convolutional network (from MNIST example) but can be easily extended. There are implemented only ReLU and Softmax activations.

It is working with the Theano backend - support for Tensorflow will be added soon.


  1. Save your network weights and architecture.
  2. Dump network structure to plain text file with script.
  3. Use network with code from keras_model.h and files - see example below.


  1. Run one iteration of simple CNN on MNIST data with example/ script. It will produce files with architecture example/my_nn_arch.json and weights in HDF5 format example/my_nn_weights.h5.
  2. Dump network to plain text file python -a example/my_nn_arch.json -w example/my_nn_weights.h5 -o example/dumped.nnet.
  3. Compile example g++ -std=c++11 - see code in
  4. Run binary ./a.out - you shoul get the same output as in step one from Keras.


If you want to test dumping for your network, please use script. Please provide there your network architecture and weights. The script do following job:

  1. Dump network into text file.
  2. Generate random sample.
  3. Compute predictions from keras and keras2cpp on generated sample.
  4. Compare predictions.