将Keras模型转换为TensorFlow protobuf [英] Convert Keras model to TensorFlow protobuf

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

问题描述

我们目前使用Keras训练各种神经网络,这是理想的,因为它有一个漂亮的界面,并且相对容易使用,但我们希望能够在我们的生产环境中应用它们。



不幸的是生产环境是C ++,所以我们的计划是:




  • 使用TensorFlow后端将模型保存到protobuf

  • 将我们的生产代码链接到TensorFlow,然后加载到protobuf

$ b $不幸的是,我不知道如何访问TensorFlow保存实用程序从Keras,通常保存到HDF5和JSON。如何保存到protobuf?

解决方案

您可以通过以下方式访问TensorFlow后端:

  import keras.backend.tensorflow_backend as K 

然后你可以调用任何TensorFlow实用程序或函数像:

  K.tf.ConfigProto 


We're currently training various neural networks using Keras, which is ideal because it has a nice interface and is relatively easy to use, but we'd like to be able to apply them in our production environment.

Unfortunately the production environment is C++, so our plan is to:

  • Use the TensorFlow backend to save the model to a protobuf
  • Link our production code to TensorFlow, and then load in the protobuf

Unfortunately I don't know how to access the TensorFlow saving utilities from Keras, which normally saves to HDF5 and JSON. How do I save to protobuf?

解决方案

You can access TensorFlow backend by:

import keras.backend.tensorflow_backend as K

Then you can call any TensorFlow utility or function like:

K.tf.ConfigProto

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

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