Using CNTK as a Backend for Keras

I've been learning about Keras through the Deep Learning with Python book (which I'll be doing a review of), and it can be a bit tricker to get started than just running a single pip command to install a package.

 
 

First make sure you have Keras and CNTK installed.

pip install keras
pip install cntk

You may see documentation about installing CNTK by using the wheel, but since March, 2018 it is now on PyPI so you can directly install it like above.

The easiest way to change it is to go to your user home folder and navigate to the .keras folder. There you'll see a keras.json file. This file has some configurations for Keras to use when running.

{
    "floatx": "float32",
    "epsilon": 1e-07,
    "backend": "tensorflow",
    "image_data_format": "channels_last"
}

You can change the backend property to cntk and then next time you run Keras it will use it.

Using CNTK backend
C:\Users\chron\Anaconda3\lib\site-packages\keras\backend\cntk_backend.py:21: UserWarning: CNTK backend warning: GPU is not detected. CNTK's CPU version is not fully optimized,please run with GPU to get better performance.
  'CNTK backend warning: GPU is not detected. '