amir-abdi / keras_to_tensorflow

General code to convert a trained keras model into an inference tensorflow model
MIT License
1.67k stars 540 forks source link

TensorFlow2.0 #89

Open entrehuihui opened 5 years ago

entrehuihui commented 5 years ago

I found that the script does not seem to support TensorFlow2.0. I don't know if it is my own problem..

frozen_graph = freeze_session(tf.keras.backend.get_session(), output_names=[ AttributeError: module 'tensorflow.python.keras.api._v2.keras.backend' has no attribute 'get_session'

amir-abdi commented 5 years ago

No, I have not yet made this compatible with TensorFlow 2.0

You can provide me with a link to some of your models (both TensorFlow 1.0 and 2.0). I will then use them as test files to extend the current implementation and make sure it's compatible with yours.

bonlime commented 5 years ago

I don't think you can make this script compatible with TF 2.0. They made a really huge change, now there is no such thing as session and there is no such thing as frozen graph.

yan12125 commented 4 years ago

I managed to convert a Keras model.h5 to a tensorflow saved_model.pb with the following one-liner

tf.keras.models.save_model(network,"model_save_path")

I found this from a Chinese blog post at https://blog.csdn.net/u012995500/article/details/103575879.

Tested Tensorflow version: 2.2.0