Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CNTK as keras backend #6800

Merged
merged 101 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
f2dc253
merge CNTK support
chentaMS Mar 23, 2017
95d8e19
fix merge bugs
chentaMS Mar 23, 2017
703be00
fix rebase error
chentaMS May 16, 2017
fdba0ea
fix merge error
chentaMS May 16, 2017
5e6ca8b
fix unit test failure
chentaMS May 17, 2017
3eee73f
fix comments in CR
chentaMS May 18, 2017
4354069
move recurrent modification to cntk wrapper
chentaMS May 18, 2017
85db861
fix recurrent issue and cntk identical issue
chentaMS May 18, 2017
5ce4a0a
reshape batch
chentaMS May 18, 2017
a07b9c5
move out special handle in recurrent layer code
chentaMS May 18, 2017
93a2b1e
add flattern; remove useless code
chentaMS May 21, 2017
f1c1a3c
remove useless code
chentaMS May 22, 2017
2b1302e
fix merge error
chentaMS May 22, 2017
c887817
use broadcast_as; and fix perf issue
chentaMS May 22, 2017
a3784ab
Updated backend.md to include CNTK as available backend
prasanthpul May 24, 2017
f7f90da
update according to cnkt latest master intferface
chentaMS May 24, 2017
48eb428
Updated index.md to remove toolkit names from title
prasanthpul May 24, 2017
04bd2e5
Updated README.md to include CNTK
prasanthpul May 24, 2017
8b5fbe2
Updated README.md installation instructions for CNTK
prasanthpul May 24, 2017
f5e7689
Updated faq.md for CNTK
prasanthpul May 24, 2017
5550250
fix channel_first issue
chentaMS May 25, 2017
db740ba
fix recurrent layer issue
chentaMS May 25, 2017
0137f87
batch learner
chentaMS May 25, 2017
bdee5c9
Merge remote-tracking branch 'origin/CNTKDocs' into chenta/keras-ci
chentaMS May 26, 2017
3b80376
add docs for cpu warning and examples
chentaMS May 26, 2017
db1a340
Merge remote-tracking branch 'cntk_keras/chenta/keras-ci' into cntk_k…
chentaMS May 26, 2017
1416e1b
merge CNTK support
chentaMS Mar 23, 2017
bb44aa4
fix merge bugs
chentaMS Mar 23, 2017
cd8b70e
fix rebase error
chentaMS May 16, 2017
36ea1fb
fix merge error
chentaMS May 16, 2017
0298cc3
fix unit test failure
chentaMS May 17, 2017
8d1cfa6
fix comments in CR
chentaMS May 18, 2017
53fb1a7
move recurrent modification to cntk wrapper
chentaMS May 18, 2017
fe0c6cb
fix recurrent issue and cntk identical issue
chentaMS May 18, 2017
ba0fe21
reshape batch
chentaMS May 18, 2017
7b19f92
move out special handle in recurrent layer code
chentaMS May 18, 2017
67e769f
add flattern; remove useless code
chentaMS May 21, 2017
43f4cdd
remove useless code
chentaMS May 22, 2017
32c9a7c
use broadcast_as; and fix perf issue
chentaMS May 22, 2017
2df406e
Updated backend.md to include CNTK as available backend
prasanthpul May 24, 2017
ad2a3a3
update according to cnkt latest master intferface
chentaMS May 24, 2017
5d05a9f
Updated index.md to remove toolkit names from title
prasanthpul May 24, 2017
2c3d71e
Updated README.md to include CNTK
prasanthpul May 24, 2017
9abf80d
Updated README.md installation instructions for CNTK
prasanthpul May 24, 2017
1e0e53c
Updated faq.md for CNTK
prasanthpul May 24, 2017
6a423f7
fix channel_first issue
chentaMS May 25, 2017
351254a
fix recurrent layer issue
chentaMS May 25, 2017
52d4ba4
batch learner
chentaMS May 25, 2017
22c83f1
add docs for cpu warning and examples
chentaMS May 26, 2017
48befe9
remove the python workaround for learner
chentaMS May 27, 2017
5eb6507
fix merge conflict
chentaMS May 27, 2017
7279afb
fix pep8 error
chentaMS May 27, 2017
9a12fe4
update README with CNTK
n17s May 27, 2017
af4d68f
Merge pull request #1 from n17s/patch-1
souptc May 27, 2017
c9d53b6
fix merge err
chentaMS May 27, 2017
4d28762
fix python 27 issue
chentaMS May 30, 2017
f0a3c7d
revert useless code
chentaMS May 30, 2017
5170068
install cntk for ci test
chentaMS May 30, 2017
961a705
fix format issue
chentaMS May 30, 2017
9171052
fix file name issue
chentaMS May 30, 2017
99b64bc
fix pip install issue
chentaMS May 30, 2017
1a1561a
fix typo
chentaMS May 30, 2017
6cf75ac
remove useless code
chentaMS May 30, 2017
7fc43e5
install mpi
chentaMS May 30, 2017
b2666c9
fix folder issue
chentaMS May 30, 2017
1971956
use cpu build
chentaMS May 30, 2017
7a774fb
add mpi support
chentaMS May 31, 2017
e2bad15
add cntk into test job
chentaMS May 31, 2017
bbf80ab
remove useless code
chentaMS May 31, 2017
542ccaf
fix pep8 issue
chentaMS May 31, 2017
4afd146
fix missing parameter
chentaMS May 31, 2017
3839aa6
install cntk for ci test
chentaMS May 30, 2017
003d3da
move the warning message from example to cntk backend; fix error in d…
chentaMS May 31, 2017
834c357
fix merge error
chentaMS May 31, 2017
f2283e1
revert out of date constrains change
chentaMS May 31, 2017
5422e44
support bias shape in bias_add
chentaMS May 31, 2017
880f957
add local_conv api; remove useless changes
chentaMS Jun 1, 2017
5e58274
install pre-build openmpi
chentaMS Jun 1, 2017
35b51d4
add more ut
chentaMS Jun 1, 2017
336ae36
remove blank lines
chentaMS Jun 1, 2017
760a36f
Merge branch 'master' into master
souptc Jun 1, 2017
0902de5
update install cmd with cntk 2.0 offical build; fix typos in test file
chentaMS Jun 2, 2017
c580ca0
use broadcast way to avoid dropout in recurrent layer change
chentaMS Jun 2, 2017
e441f64
fix comments in pr
chentaMS Jun 3, 2017
efd1edd
using the same weight name strategy as theano
chentaMS Jun 3, 2017
94d1616
Merge branch 'fix_issues'
chentaMS Jun 3, 2017
e16848a
fix the equal issue
chentaMS Jun 5, 2017
48c83e0
add the list type check
chentaMS Jun 5, 2017
3f84890
Add sparse_top_k_categorical_accuracy and test code (#6840)
Vimos Jun 4, 2017
4349d29
skip sparse top k test for cntk since cntk not support it now
chentaMS Jun 5, 2017
8a93935
Merge branch 'master' into master
souptc Jun 5, 2017
c93e8c1
avoid extra agument bias_shape
chentaMS Jun 5, 2017
461c43c
fix style issue
chentaMS Jun 6, 2017
37db64d
update the ut of bias_add
chentaMS Jun 5, 2017
59bda65
update the year
chentaMS Jun 6, 2017
d69553e
fix too long lines and doc strings
chentaMS Jun 6, 2017
8884013
fix line endings
chentaMS Jun 6, 2017
1e1ebbd
Merge branch 'test_cr' into fix_style
chentaMS Jun 6, 2017
7fb38b1
Merge remote-tracking branch 'keras-master/master'
chentaMS Jun 6, 2017
1eca798
skip stateful recurrent test for cntk
chentaMS Jun 7, 2017
82832a3
fix reshape issue with inferred dimension
chentaMS Jun 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ matrix:
env: KERAS_BACKEND=theano
- python: 3.5
env: KERAS_BACKEND=theano
- python: 2.7
env: KERAS_BACKEND=cntk
- python: 3.5
env: KERAS_BACKEND=cntk
install:
# code below is taken from http://conda.pydata.org/docs/travis.html
# We do this conditionally because it saves us some downloading if the
Expand Down Expand Up @@ -49,6 +53,22 @@ install:

# install TensorFlow (CPU version).
- pip install tensorflow

# install cntk
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0-cp27-cp27mu-linux_x86_64.whl;
elif [[ "$TRAVIS_PYTHON_VERSION" == "3.5" ]]; then
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0-cp35-cp35m-linux_x86_64.whl;
fi

#install open mpi
- rm -rf ~/mpi
- mkdir ~/mpi
- pushd ~/mpi
- wget http://cntk.ai/PythonWheel/ForKeras/depends/openmpi_1.10-3.zip
- unzip ./openmpi_1.10-3.zip
- sudo dpkg -i openmpi_1.10-3.deb
- popd

# command to run tests
script:
Expand Down
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All contributions by Google:
Copyright (c) 2015, Google, Inc.
All rights reserved.

All contributions by Microsoft:
Copyright (c) 2017, Microsoft, Inc.
All rights reserved.

All other contributions:
Copyright (c) 2015 - 2017, the respective contributors.
All rights reserved.
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Keras: Deep Learning library for TensorFlow and Theano
# Keras: Deep Learning library for TensorFlow, CNTK, and Theano

[![Build Status](https://travis-ci.org/fchollet/keras.svg?branch=master)](https://travis-ci.org/fchollet/keras)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/fchollet/keras/blob/master/LICENSE)

## You have just found Keras.

Keras is a high-level neural networks API, written in Python and capable of running on top of either [TensorFlow](https://github.com/tensorflow/tensorflow) or [Theano](https://github.com/Theano/Theano). It was developed with a focus on enabling fast experimentation. *Being able to go from idea to result with the least possible delay is key to doing good research.*
Keras is a high-level neural networks API, written in Python and capable of running on top of either [TensorFlow](https://github.com/tensorflow/tensorflow) [CNTK](https://github.com/Microsoft/cntk) or [Theano](https://github.com/Theano/Theano). It was developed with a focus on enabling fast experimentation. *Being able to go from idea to result with the least possible delay is key to doing good research.*

Use Keras if you need a deep learning library that:

Expand Down Expand Up @@ -125,6 +125,11 @@ Keras uses the following dependencies:
- TensorFlow
- [See installation instructions](https://www.tensorflow.org/install/).

*When using the CNTK backend:*

- CNTK
- [See installation instructions](https://docs.microsoft.com/en-us/cognitive-toolkit/setup-cntk-on-your-machine).

*When using the Theano backend:*

- Theano
Expand All @@ -143,7 +148,7 @@ sudo pip install keras
------------------


## Switching from TensorFlow to Theano
## Switching from TensorFlow to CNTK or Theano

By default, Keras will use TensorFlow as its tensor manipulation library. [Follow these instructions](http://keras.io/backend/) to configure the Keras backend.

Expand Down
9 changes: 5 additions & 4 deletions docs/templates/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

Keras is a model-level library, providing high-level building blocks for developing deep learning models. It does not handle itself low-level operations such as tensor products, convolutions and so on. Instead, it relies on a specialized, well-optimized tensor manipulation library to do so, serving as the "backend engine" of Keras. Rather than picking one single tensor library and making the implementation of Keras tied to that library, Keras handles the problem in a modular way, and several different backend engines can be plugged seamlessly into Keras.

At this time, Keras has two backend implementations available: the **TensorFlow** backend and the **Theano** backend.
At this time, Keras has three backend implementations available: the **TensorFlow** backend, the **Theano** backend, and the **CNTK** backend.

- [TensorFlow](http://www.tensorflow.org/) is an open-source symbolic tensor manipulation framework developed by Google, Inc.
- [Theano](http://deeplearning.net/software/theano/) is an open-source symbolic tensor manipulation framework developed by LISA/MILA Lab at Université de Montréal.
- [CNTK](https://www.microsoft.com/en-us/cognitive-toolkit/) is an open-source, commercial-grade toolkit for deep learning developed by Microsoft.

In the future, we are likely to add more backend options. Go ask Microsoft about how their CNTK backend project is doing.
In the future, we are likely to add more backend options.

----

Expand All @@ -34,7 +35,7 @@ The default configuration file looks like this:
}
```

Simply change the field `backend` to either `"theano"` or `"tensorflow"`, and Keras will use the new configuration next time you run any Keras code.
Simply change the field `backend` to `"theano"`, `"tensorflow"`, or `"cntk"`, and Keras will use the new configuration next time you run any Keras code.

You can also define the environment variable ``KERAS_BACKEND`` and this will
override what is defined in your config file :
Expand Down Expand Up @@ -65,7 +66,7 @@ You can change these settings by editing `$HOME/.keras/keras.json`.
- For 3D data, `"channels_last"` assumes `(conv_dim1, conv_dim2, conv_dim3, channels)` while `"channels_first"` assumes `(channels, conv_dim1, conv_dim2, conv_dim3)`.
* `epsilon`: float, a numeric fuzzing constant used to avoid dividing by zero in some operations.
* `floatx`: string, `"float16"`, `"float32"`, or `"float64"`. Default float precision.
* `backend`: string, `"tensorflow"` or `"theano"`.
* `backend`: string, `"tensorflow"`, `"theano"`, or `"cntk"`.

----

Expand Down
2 changes: 1 addition & 1 deletion docs/templates/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Please cite Keras in your publications if it helps your research. Here is an exa

### How can I run Keras on GPU?

If you are running on the TensorFlow backend, your code will automatically run on GPU if any available GPU is detected.
If you are running on the TensorFlow or CNTK backends, your code will automatically run on GPU if any available GPU is detected.

If you are running on the Theano backend, you can use one of the following methods:

Expand Down
2 changes: 1 addition & 1 deletion docs/templates/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Keras: Deep Learning library for Theano and TensorFlow
# Keras: The Python Deep Learning library

{{autogenerated}}
9 changes: 6 additions & 3 deletions keras/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
_epsilon = _config.get('epsilon', epsilon())
assert isinstance(_epsilon, float)
_backend = _config.get('backend', _BACKEND)
assert _backend in {'theano', 'tensorflow'}
assert _backend in {'theano', 'tensorflow', 'cntk'}
_image_data_format = _config.get('image_data_format',
image_data_format())
assert _image_data_format in {'channels_last', 'channels_first'}
Expand Down Expand Up @@ -68,11 +68,14 @@
# Set backend based on KERAS_BACKEND flag, if applicable.
if 'KERAS_BACKEND' in os.environ:
_backend = os.environ['KERAS_BACKEND']
assert _backend in {'theano', 'tensorflow'}
assert _backend in {'theano', 'tensorflow', 'cntk'}
_BACKEND = _backend

# Import backend functions.
if _BACKEND == 'theano':
if _BACKEND == 'cntk':
sys.stderr.write('Using CNTK backend\n')
from .cntk_backend import *
elif _BACKEND == 'theano':
sys.stderr.write('Using Theano backend.\n')
from .theano_backend import *
elif _BACKEND == 'tensorflow':
Expand Down
Loading