Skip to content

Instantly share code, notes, and snippets.

@framsc
framsc / README.md
Created May 13, 2019 08:50 — forked from asimshankar/README.md
Training TensorFlow models in C

Training TensorFlow models in C

Python is the primary language in which TensorFlow models are typically developed and trained. TensorFlow does have bindings for other programming languages. These bindings have the low-level primitives that are required to build a more complete API, however, lack much of the higher-level API richness of the Python bindings, particularly for defining the model structure.

This gist demonstrates taking a model (a TensorFlow graph) created by a Python program and running the training loop in a C program.

The model

@framsc
framsc / ctypes_stuff.py
Created January 5, 2019 15:28 — forked from nicolamontecchio/ctypes_stuff.py
python ctypes - array conversion
#let's say f_TI is something like
#void blabla(int *data, int data_length);
#then
f_TI.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.c_int]
lll = [4,7,2,8]
lll_c = (ctypes.c_int * len(lll))(*lll)
f_TI(lll_c, len(lll))