将Keras模型转换为TensorFlow protobuf [英] Convert Keras model to TensorFlow protobuf
问题描述
我们目前使用Keras训练各种神经网络,这是理想的,因为它有一个漂亮的界面,并且相对容易使用,但我们希望能够在我们的生产环境中应用它们。
不幸的是生产环境是C ++,所以我们的计划是:
- 使用TensorFlow后端将模型保存到protobuf
- 将我们的生产代码链接到TensorFlow,然后加载到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屋!