Use Core ML to integrate machine learning models into your app. Core ML provides a unified representation for all models. Your app uses Core ML APIs and user data to make predictions, and to train or fine-tune models, all on the user’s device.

Core ML optimizes on-device performance by leveraging the CPU, GPU, and Neural Engine while minimizing its memory footprint and power consumption. Running a model strictly on the user’s device removes any need for a network connection, which helps keep the user’s data private and your app responsive.

Multi-backend Keras


Deprecated in the next version

Support for Multi-backend Keras will be deprecated in the next version of coremltools.


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.

Updated 11 months ago

Multi-backend Keras

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.