Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.18 KB

README.md

File metadata and controls

64 lines (48 loc) · 2.18 KB

Tensorflow examples for C/C++

This project includes source code for my blog:

  1. Tensorflow C: from training to serving (In Chinese)

  2. Tensorflow C++: from training to serving (In Chinese)

996.icu

1. Dependancies

  1. For C API, download sdk from https://www.tensorflow.org/install/lang_c and put it into third_party/tensorflow_cpu (default) or third_party/tensorflow_gpu folder.

  2. For C++ API, follow the steps in Tensorflow C++: from training to serving (In Chinese) or Tensorflow C++ API to build tensorflow on your platform.

The C++ API is only designed to work with TensorFlow bazel build, which means you have to build tensorflow on every devices. If you need a stand-alone option, we suggest you use the C API.

2. Build

Prepare

mkdir build
cd build

CMake

For C API, run:

cmake .. -DUSE_TENSORFLOW_C=ON

For C++ API, run:

cmake .. -DUSE_TENSORFLOW_CPP=ON

Build

make

3. Run

For C++ Example (Simple Net)

./load_simple_net ../simple/model/simple.pb

For C++ Example (CNN Net)

./load_predict_cnn ../fashion_mnist/models/fashion_mnist.h5.pb ../fashion_mnist/fashion_0.png

For C Example (Simple Net)

./load_simple_net_c_api ../simple/model/simple.pb

For C Example (CNN Net)

./load_predict_cnn_c_api ../fashion_mnist/models/fashion_mnist.h5.pb ../fashion_mnist/fashion_0.png

Contact

My Blog: www.liuxiao.org

If you have any question, please contact liuxiao at foxmail.com