将Keras模型转换为C ++ [英] Convert Keras model to C++

查看:114
本文介绍了将Keras模型转换为C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Keras(与Theano)来训练CNN模型.有谁知道如何在我的C ++应用程序中使用它?有人尝试过类似的东西吗?我有想法写一些Python代码,这些代码将生成具有网络功能的C ++代码-对此有何建议?

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?

我在此处找到了类似的问题 C ++,但没有答案.

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

推荐答案

要回答我自己的问题并找到解决方案-我写了一个简单的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.

这篇关于将Keras模型转换为C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆