Felix Goldberg
Felix Goldberg

Reputation: 421

How to convert a Tensorflow session to a keras model object?

Suppose I have a pre-trained model stored in a Tensorflow checkpoint. I'd like to convert it into a Keras model. I can load the checkpoint into a TF session alright but that's where I get stuck.

Upvotes: 1

Views: 1030

Answers (1)

Natthaphon Hongcharoen
Natthaphon Hongcharoen

Reputation: 2440

I think it's impossible to create a Keras model using TF checkpoint, but you can copy it's weights to the already created Keras model.

Checkout this. https://github.com/yuyang-huang/keras-inception-resnet-v2

The extract_weights.py is to save the TF weights to numpy array, while load_weights.py is for load the npy file to the Keras model.

For more reference, this is how I implement it https://github.com/DableUTeeF/keras-efficientnet/tree/master/keras_efficientnet.

Upvotes: 1

Related Questions