How to save a Keras model in the CNTK format

Viewed 2773

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')
3 Answers

I use this converter to convert models between keras and CNTK.

  1. Save keras model model.save('keras_model.h5')

  2. Install converter pip install -U git+https://github.com/Microsoft/MMdnn.git@master

  3. Run command: mmconvert -sf keras -iw keras_model.h5 -df cntk -om cntk_model.dnn
Related