Multi-backend Keras

❗️

Keras and Tensorflow.Keras are not the same

Multi-backend Keras is the version of Keras that supports multiple backends including CNTK and Theano. The TensorFlow Keras API supports only TensorFlow.

You can convert to Core ML models created with Multi-backend Keras using a TensorFlow 1.x backend, and saved in the .h5 format.

If you are using Keras APIs with TensorFlow 2, use the tf.keras APIs directly, and convert the resulting tf.keras model with the Unified Conversion API. The coremltools Keras converter supports Keras version 2.2+.

🚧

In maintenance mode

Multi-backend Keras is no longer provided. The Multi-backend Keras convertor is not part of the Unified Conversion API. It is in maintenance mode, so additional features will not be added.

The following is an example of converting a model from Multi-backend Keras using either a path or a model object:

import coremltools as ct

# Convert by providing path to a .h5 file
model = ct.converters.keras.convert('keras_model.h5')

# Convert by providing a Keras model object
from keras.models import load_model
keras_model = load_model("keras_model.h5")

model = ct.converters.keras.convert(keras_model)

For a complete list of arguments that can be passed to the convert() method, see the API reference.