[PYTHON] Use the Cognitive Took Kit (CNTK) with the Keras backend

CNTK version 2.1

CNTK is also version 2.1. The characteristic of the enhancements related to 2.1 is that deeprl is provided as a framework for reinforcement learning. You can find a reference at the link below. It seems that some logic is implemented besides Deep Q-Learning. •cntk.contrib.deeprl.agent.agent modulecntk.contrib.deeprl.agent.agent_factory modulecntk.contrib.deeprl.agent.policy_gradient modulecntk.contrib.deeprl.agent.qlearning modulecntk.contrib.deeprl.agent.random_agent modulecntk.contrib.deeprl.agent.tabular_qlearning module Also, although it has been supported since 2.0, it is becoming more widely used as it can be used as a backend for Keras.

Keras example

I would like to introduce [Using Keras and Deep Q-Network to Play Flappy Bird] as an example of Keras. Originally created by Keras, it is a sample of reinforcement learning, but it has been ported to CNTK. The code is published in cntk / Examples / Reinforcement Learning / FlappingBirdWithKeras. Let's move the sample. Since the installation setup of CNTK is the same as in the RC era, [this article](https://analyticsai.wordpress.com/2017/04/04/cntk2-0b15%e3%82%a4%e3%83%b3 See% e3% 82% b9% e3% 83% 88% e3% 83% bc% e3% 83% ab /).

Keras can be installed from the command line that activates cntk below (it is better to upgrade to the latest version, so if you already have it installed, you should add the -U option)

pip install keras

In addition, create a configuration file ~ / .keras / keras.json. For Windows it will be C: \ Users \ \ .keras.json. The contents of the file are as follows.

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

With the above, keras can be operated. You can check the operation below.

・ In case of GPU operation (It takes a terrible time without GPU) https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py

・ When GPU is not included https://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py I think it is good. Then install the Flapping Bird dependencies

pip install pygame conda install scikit-learn conda install scikit-image

In this state, it can operate on both Windows and Linux. Also, since it runs on the GPU, you can expect high-speed operation.

Runs on Ubuntu 16.04 LTS

screenshot-from-2017-08-03-14-52-55[1].png

screenshot-from-2017-08-03-14-52-03[1].png

screenshot-from-2017-08-03-14-52-30[1].png

CNTK is also 2.1 and various parts have been strengthened. The evolution of the field of enhanced learning is expected in the future.

Recommended Posts

Use the Cognitive Took Kit (CNTK) with the Keras backend
Run Keras with CNTK backend from CentOS
MNIST (DCNN) with Keras (TensorFlow backend)
Use the preview feature with aws-cli
Use TPU and Keras with Google Colaboratory
Add a layer using the Keras backend
Try to solve the fizzbuzz problem with Keras
Exposing the DCGAN model for Cifar 10 with keras
Until you use the Kaggle API with Colab
Specify the Python executable to use with virtualenv
Use logger with Python for the time being
The easiest way to use OpenCV with python