Search code examples
pythonkerasios11coreml

CoreML load model saved with Keras 2


Apple's new CoreML can work with models trained on popular framework. At least they say so at 18" in the WWDC video. But in the docs it seems that concerning neural nets they only support Caffe and Keras 1.2.2 (see code), while Keras it on it 2.0 version and Tensorflow and Theano are quite popular in their own rights.

To get the conversion running with Keras 2, is there a better way than implementing the conversion myself? The Keras conversion code in the coremltools package is ~2000 lines longs and I don't have a deep knowledge of all Keras model representation so I really don't want to go that route.

I've tried converting a model saved with Keras 2 directly, but that doesn't work and fails with

TypeError: ('Keyword argument not understood:', u'gamma_initializer')

from site-packages/keras/engine/topology.py", line 326

They also don't have a github for coremltools so it's hard to discuss this package in more details. I've uploaded a copy of the package: https://github.com/gsabran/coremltools


Solution

  • Keras 2.0 support is already there (released yesterday), with coremltools v.0.4.0

    Also, refer to newest comments on Apple Developer Forums