Is there a way to save a Keras model to the format of CNTK so that we can load it by using CNTK's API?
I have tried this code below but it failed:
a = Input(shape=(224,224,3))
b = Conv2D(64, (2,2), name='conv1')(a)
model = Model(inputs=a, outputs=b)
cntk.combine(model.outputs).save('model2.dnn')
Please see Keras-CNTK saving model-v2 format
To save Keras model in CNTK format (when using CNTK as back end):
import cntk as C
from keras.backend import load_model
keras_model = load_model('my_keras_model.h5')
cntk.combine(keras_model.model.outputs).save('my_cntk_model')
cntk_model = C.load_model('my_cntk_model')
To save Keras in TensorFlow format (when using TensorFlow as backend):
model = load_model('model2.h5')
sess = K.get_session()
tf_saver = tf.train.Saver()
tf_saver.save(sess=sess, save_path=checkpoint_path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With