且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Keras模型转换为C ++

更新时间:2022-05-07 23:35:53

要回答我自己的问题并找到解决方案-我写了一个简单的c ++解决方案,名为

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

在此解决方案中,您将存储网络体系结构(在json中)和权重(在hdf5中).然后,您可以使用提供的脚本将网络转储到纯文本文件.您可以使用纯c ++代码在网络上使用获得的文本文件. python库或hdf5没有依赖关系.它应该适用于theano和tensorflow后端.

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.