Keras can be installed using
pip
or
conda
. Before installation, make sure you have Python >= 3.5, as Keras does not support Python 2.
1. Installing Keras :
Using pip
:
pip install tensorflow # Install TensorFlow backend as Keras may not work without TensorFlow.?
pip install keras
Using conda
(recommended with Anaconda distribution) :
conda install -c conda-forge keras
conda install -c conda-forge tensorflow?
If using TensorFlow as the Keras backend, it is recommended to install Keras with TensorFlow as it is incorporated better.
2. Setting Keras Backend :
After the installation, you may need to configure the Keras backend. If using TensorFlow and installed it separately, you typically don't need to set it up; otherwise, to link Keras to TensorFlow, run the following Python code:
import os
os.environ['KERAS_BACKEND'] = 'tensorflow'?
3. Verifying the Installation :
To check if Keras is installed and set up correctly, import Keras and verify the configuration using the following Python code:
import keras
from keras import backend as K
print(keras.__version__) # Display Keras version.
print(K.backend()) # Display the current backend (e.g., 'tensorflow').?