Keras: Examples to convert tensorflow trained model to Keras model

Created on 9 Aug 2017  路  7Comments  路  Source: keras-team/keras

It would be nice to include an example showing how to programmatically convert a tensorflow model to keras model such that model learns from Tensorflow can be imported into Keras for further development/experiment.

stale

Most helpful comment

How can I convert a .pb file to .h5? I have frozen_inference_graph.pb from tensorflow and I need to have that model in h5 format for loading weights in Keras

All 7 comments

TF is much more flexible than Keras. Making a parser from TF to Keras would be a humongous task.
Has anyone started a project like that?

TF at its core has no concept of layers it's just a big graph.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

How can I convert a .pb file to .h5? I have frozen_inference_graph.pb from tensorflow and I need to have that model in h5 format for loading weights in Keras

same as @dextroza

@dextroza @GustavZ I think you might benefit from this issue:
https://github.com/keras-team/keras/issues/8026

If you want to convert only weights (suppose you have code for the same model), you have to create model with random weights (you can find InceptionV3 in keras.applications) then read the TensorFlow .ckpt file with tf.train.NewCheckpointReader then call set_weights() method for each corresponding layer.

@bottydim thank you for the suggestion!

Was this page helpful?
0 / 5 - 0 ratings