Patches in a PlaidML backend for Keras.

This module hooks the system meta module path to add a backend for Keras that uses PlaidML for computation. The actual backend is implemented in

To use this module to install the PlaidML backend:

import plaidml.keras

This should be done in the main program module, after __future__ imports (if any) and before importing any Keras modules. Calling install() replaces the standard keras.backend module with plaidml.keras.backend, causing subsequently loaded Keras modules to use PlaidML.

You can explicitly set the installed backend via the environment:
PLAIDML_KERAS_BACKEND: Selects the backend to use.
If this is not set, the standard PlaidML backend is used. Possible values are “plaidml” and “theano”.

You can also explicitly pass the backend in the call to install_backend().

(As an aside: we don’t use the standard Keras approach of having you edit ~/.keras/keras.json to set the backend, because we want code that doesn’t patch in the PlaidML backend loader to continue to work. If Keras ever does support dynamic loading of backends that aren’t hard-coded into Keras, we will switch to that mechanism.)


install_backend([import_path, backend, …]) Installs the PlaidML backend loader, overriding the default keras.