Skip to main content

Introduction to Keras

Shanghai, China

Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It was developed with a focus on enabling fast experimentation.

Installation of Keras

You can install TensorFlow directly through pip3 install keras (make sure you have Python v3 installed).

I have Anaconda set up on my computer and am going to use it for this instead. If you already have Anaconda installed, make sure that it is up to date (make sure that you start the Anaconda Prompt with Admin privileges):

conda update conda
conda update anaconda

Anaconda allows us to create a virtual environment in which we can run our TensorFlow and Keras program. To create the environment with the name py3-TF2 run the following command in the Anaconda Prompt - hit y when prompted:

conda create --name py3-TF2 python=3
conda activate py3-TF2

Before installing Keras, please install one of its backend engines: TensorFlow, Theano, or CNTK. We recommend the TensorFlow backend. We can now continue installing Keras inside this virtual environment:

pip install keras

To be able to use the virtual environment in Jupyter Notebook we need to install ipykernel and nb_conda_kernels inside it:

pip install ipykernel
conda install nb_conda_kernels