NVIDIA/keras

Name: keras

Owner: NVIDIA Corporation

Description: null

Created: 2017-08-10 22:05:09.0

Updated: 2018-03-28 18:34:37.0

Pushed: 2017-08-15 21:16:30.0

Homepage: null

Size: 5886

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Keras: Deep Learning library for MxNet, TensorFlow and Theano

Build Status license

You have just found Keras.

Keras is a high-level neural networks library, written in Python and capable of running on top of MxNet, TensorFlow or 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:

Read the documentation at Keras.io.

Keras is compatible with: Python 2.7-3.5.


Guiding principles

Getting started: 30 seconds to Keras

The core data structure of Keras is a model, a way to organize layers. The main type of model is the Sequential model, a linear stack of layers. For more complex architectures, you should use the Keras functional API.

Here's the Sequential model:

 keras.models import Sequential

l = Sequential()

Stacking layers is as easy as .add():

 keras.layers import Dense, Activation

l.add(Dense(output_dim=64, input_dim=100))
l.add(Activation('relu'))
l.add(Dense(output_dim=10))
l.add(Activation('softmax'))

Once your model looks good, configure its learning process with .compile():

l.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy'])

If you need to, you can further configure your optimizer. A core principle of Keras is to make things reasonably simple, while allowing the user to be fully in control when they need to (the ultimate control being the easy extensibility of the source code).

 keras.optimizers import SGD
l.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.01, momentum=0.9, nesterov=True))

You can now iterate on your training data in batches:

l.fit(X_train, Y_train, nb_epoch=5, batch_size=32)

Alternatively, you can feed batches to your model manually:

l.train_on_batch(X_batch, Y_batch)

Evaluate your performance in one line:

_and_metrics = model.evaluate(X_test, Y_test, batch_size=32)

Or generate predictions on new data:

ses = model.predict_classes(X_test, batch_size=32)
a = model.predict_proba(X_test, batch_size=32)

Building a question answering system, an image classification model, a Neural Turing Machine, a word2vec embedder or any other model is just as fast. The ideas behind deep learning are simple, so why should their implementation be painful?

For a more in-depth tutorial about Keras, you can check out:

In the examples folder of the repository, you will find more advanced models: question-answering with memory networks, text generation with stacked LSTMs, etc.


Installation

Keras uses the following dependencies:

When using the MxNet backend:

Note: MxNet backend is the only one that currently has automatic multi-GPU capability.

Note: It is highly recommended that MxNet is installed based on compiling from source, especially if using CUDA > 8.

When using the TensorFlow backend:

When using the Theano backend:

To install Keras, cd to the Keras folder and run the install command:

 python setup.py install

You can also install Keras from PyPI:

 pip install keras

Switching from TensorFlow to Theano

By default, Keras will use TensorFlow as its tensor manipulation library. Follow these instructions to configure the Keras backend.


Support

You can ask questions and join the development discussion:

You can also post bug reports and feature requests (only) in Github issues. Make sure to read our guidelines first.


Why this name, Keras?

Keras (?????) means horn in Greek. It is a reference to a literary image from ancient Greek and Latin literature, first found in the Odyssey, where dream spirits (Oneiroi, singular Oneiros) are divided between those who deceive men with false visions, who arrive to Earth through a gate of ivory, and those who announce a future that will come to pass, who arrive through a gate of horn. It's a play on the words ????? (horn) / ?????? (fulfill), and ?????? (ivory) / ??????????? (deceive).

Keras was initially developed as part of the research effort of project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System).

“Oneiroi are beyond our unravelling –who can be sure what tale they tell? Not all that men look for comes to pass. Two gates there are that give passage to fleeting Oneiroi; one is made of horn, one of ivory. The Oneiroi that pass through sawn ivory are deceitful, bearing a message that will not be fulfilled; those that come out through polished horn have truth behind them, to be accomplished for men who see them.“ Homer, Odyssey 19. 562 ff (Shewring translation).



This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.