When comparing **Keras** vs **Theano**, the Slant community recommends **Theano** for most people. In the question**“What are the best artificial intelligence frameworks?”** **Theano** is ranked 1st while **Keras** is ranked 3rd. The most important reason people chose **Theano** is:

Theano is a Python library which is very well adapted for numerical tasks often encountered when dealing with deep learning. What makes it well adapted for those tasks is the fact that it combines several paradigms for numerical computations, namely: matrix operations symbolic variable and function definitions Just-in-time compilation to CPU or GPU machine code

#### Specs

#### Ranked in these QuestionsQuestion Ranking

#### Pros

### Pro Runs on top of Theano, TensorFlow or CNTK

You can choose the back-end for Keras. Simply change the backend field to "theano", "tensorflow", or "cntk".

Theano was discontinued in 2017, so TensorFlow or CNTK would be the better choice.

### Pro Simple to use

### Pro Can be used to write really short pieces of code

Keras enforces minimalism as much as possible. Because of this, it's possible to write a small Neural Network in just a couple of lines of code.

### Pro Really straightforward for someone who is familiar with deep learning

### Pro Quite modular

When using Keras you don't have to pull every part of the framework on your project. For example, you can only use training algorithms and not layer implementations. So it works more like a collection of libraries.

### Pro Well adapted for numerical tasks

Theano is a Python library which is very well adapted for numerical tasks often encountered when dealing with deep learning.

What makes it well adapted for those tasks is the fact that it combines several paradigms for numerical computations, namely:

matrix operations

symbolic variable and function definitions

Just-in-time compilation to CPU or GPU machine code

### Pro Optimized for both CPU and GPU

Since all variables are actually symbolic variables, you need to define a function and fill in the values in order to get a value. For example:

```
# X, y and w are a matrix and vectors respectively
# E is a scalar that depends on the above variables
# to get the value of E we must define:
Efun = theano.function([X,w,y],
E,allow_input_downcast=True)
```

While this seems like an unnecessary step, it's actually not. Since Theano now has a representation of the whole expression graph for the Efun function, it can compile and optimize the code so that it can run on both CPU and GPU.

#### Cons

### Con Little customization compared to other frameworks

Keras is a high-level API. It's difficult to customize your model past a point. If you want to build something beyond the application-level, use Theano or TensorFlow. (Keras runs on top of either one of these anyways)

### Con Somewhat low level on its own

Theano is one of the oldest deep learning libraries out there and a lot of other widely used libraries have been built on top of it.

But Theano heavily relies on the mathematical side of deep learning and data discovery, having similar features to NumPy or Matlab. This is why it's usually used with other libraries in order to achieve a higher level of abstraction.