Overview of Deep Learning Library Keras and How to install Keras Library on your machine

Last updated on Oct 30 2021
Kalpana Kapoor

Table of Contents

Overview of Deep Learning Library Keras and How to install Keras Library on your machine

Keras – Introduction

Deep learning is one of the major subfields of machine learning framework. Machine learning is the study of design of algorithms, inspired from the model of human brain. Deep learning is becoming more popular in data science fields like robotics, artificial intelligence (AI), audio & video recognition and image recognition. Artificial neural network is the core of deep learning methodologies. Deep learning is supported by various libraries such as Theano, TensorFlow, Caffe, Mxnet etc., Keras is one of the most powerful and easy to use python library, which is built on top of popular deep learning libraries like TensorFlow, Theano, etc., for creating deep learning models.

Overview of Keras

Keras runs on top of open source machine libraries like TensorFlow, Theano or Cognitive Toolkit (CNTK). Theano is a python library used for fast numerical computation tasks. TensorFlow is the most famous symbolic math library used for creating neural networks and deep learning models. TensorFlow is very flexible and the primary benefit is distributed computing. CNTK is deep learning framework developed by Microsoft. It uses libraries such as Python, C#, C++ or standalone machine learning toolkits. Theano and TensorFlow are very powerful libraries but difficult to understand for creating neural networks.

Keras is based on minimal structure that provides a clean and easy way to create deep learning models based on TensorFlow or Theano. Keras is designed to quickly define deep learning models. Well, Keras is an optimal choice for deep learning applications.

Features

Keras leverages various optimization techniques to make high level neural network API easier and more performant. It supports the following features −

  • Consistent, simple and extensible API.
  • Minimal structure – easy to achieve the result without any frills.
  • It supports multiple platforms and backends.
  • It is user friendly framework which runs on both CPU and GPU.
  • Highly scalability of computation.

Benefits

Keras is highly powerful and dynamic framework and comes up with the following advantages −

  • Larger community support.
  • Easy to test.
  • Keras neural networks are written in Python which makes things simpler.
  • Keras supports both convolution and recurrent networks.
  • Deep learning models are discrete components, so that, you can combine into many ways.

Keras – Installation

This blog furtherexplains about how to install Keras on your machine. Before moving to installation, let us go through the basic requirements of Keras.

Prerequisites

You must satisfy the following requirements −

  • Any kind of OS (Windows, Linux or Mac)
  • Python version 3.5 or higher.

Python

Keras is python based neural network library so python must be installed on your machine. If python is properly installed on your machine, then open your terminal and type python, you could see the response similar as specified below,

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18)

[MSC v.1900 64 bit (AMD64)] on win32

Type “help”, “copyright”, “credits” or “license” for more information.

>>>

As of now the latest version is ‘3.7.2’. If Python is not installed, then visit the official python link – www.python.org and download the latest version based on your OS and install it immediately on your system.

Keras Installation Steps

Keras installation is quite easy. Follow below steps to properly install Keras on your system.

Step 1: Create virtual environment

Virtualenv is used to manage Python packages for different projects. This will be helpful to avoid breaking the packages installed in the other environments. So, it is always recommended to use a virtual environment while developing Python applications.

Linux/Mac OS

Linux or mac OS users, go to your project root directory and type the below command to create virtual environment,

python3 -m venv kerasenv

After executing the above command, “kerasenv” directory is created with bin,lib and include folders in your installation location.

Windows

Windows user can use the below command,

py -m venv keras

Step 2: Activate the environment

This step will configure python and pip executables in your shell path.

Linux/Mac OS

Now we have created a virtual environment named “kerasvenv”. Move to the folder and type the below command,

$ cd kerasvenv kerasvenv $ source bin/activate

Windows

Windows users move inside the “kerasenv” folder and type the below command,

.\env\Scripts\activate

Step 3: Python libraries

Keras depends on the following python libraries.

  • Numpy
  • Pandas
  • Scikit-learn
  • Matplotlib
  • Scipy
  • Seaborn

Hopefully, you have installed all the above libraries on your system. If these libraries are not installed, then use the below command to install one by one.

numpy

pip install numpy

you could see the following response,

Collecting numpy

Downloading

https://files.pythonhosted.org/packages/cf/a4/d5387a74204542a60ad1baa84cd2d3353c330e59be8cf2d47c0b11d3cde8/

numpy-3.1.1-cp36-cp36m-macosx_10_6_intel.

macosx_10_9_intel.macosx_10_9_x86_64.

macosx_10_10_intel.macosx_10_10_x86_64.whl (14.4MB)

|████████████████████████████████| 14.4MB 2.8MB/s

pandas

pip install pandas

We could see the following response,

Collecting pandas

Downloading

https://files.pythonhosted.org/packages/cf/a4/d5387a74204542a60ad1baa84cd2d3353c330e59be8cf2d47c0b11d3cde8/

pandas-3.1.1-cp36-cp36m-macosx_10_6_intel.

macosx_10_9_intel.macosx_10_9_x86_64.

macosx_10_10_intel.macosx_10_10_x86_64.whl (14.4MB)

|████████████████████████████████| 14.4MB 2.8MB/s

matplotlib

pip install matplotlib

We could see the following response,

Collecting matplotlib

Downloading

https://files.pythonhosted.org/packages/cf/a4/d5387a74204542a60ad1baa84cd2d3353c330e59be8cf2d47c0b11d3cde8/

matplotlib-3.1.1-cp36-cp36m-macosx_10_6_intel.

macosx_10_9_intel.macosx_10_9_x86_64.

macosx_10_10_intel.macosx_10_10_x86_64.whl (14.4MB)

|████████████████████████████████| 14.4MB 2.8MB/s

scipy

pip install scipy

We could see the following response,

Collecting scipy

Downloading

https://files.pythonhosted.org/packages/cf/a4/d5387a74204542a60ad1baa84cd2d3353c330e59be8cf2d47c0b11d3cde8

/scipy-3.1.1-cp36-cp36m-macosx_10_6_intel.

macosx_10_9_intel.macosx_10_9_x86_64.

macosx_10_10_intel.macosx_10_10_x86_64.whl (14.4MB)

|████████████████████████████████| 14.4MB 2.8MB/s

scikit-learn

It is an open source machine learning library. It is used for classification, regression and clustering algorithms. Before moving to the installation, it requires the following −

  • Python version 3.5 or higher
  • NumPy version 1.11.0 or higher
  • SciPy version 0.17.0 or higher
  • joblib 0.11 or higher.

Now, we install scikit-learn using the below command −

pip install -U scikit-learn

Seaborn

Seaborn is an amazing library that allows you to easily visualize your data. Use the below command to install −

pip pip install seaborninstall -U scikit-learn

You could see the message similar as specified below −

Collecting seaborn

Downloading

https://files.pythonhosted.org/packages/a8/76/220ba4420459d9c4c9c9587c6ce607bf56c25b3d3d2de62056efe482dadc

/seaborn-0.9.0-py3-none-any.whl (208kB) 100%

|████████████████████████████████| 215kB 4.0MB/s

Requirement already satisfied: numpy> = 1.9.3 in

./lib/python3.7/site-packages (from seaborn) (1.17.0)

Collecting pandas> = 0.15.2 (from seaborn)

Downloading

https://files.pythonhosted.org/packages/39/b7/441375a152f3f9929ff8bc2915218ff1a063a59d7137ae0546db616749f9/

pandas-0.25.0-cp37-cp37m-macosx_10_9_x86_64.

macosx_10_10_x86_64.whl (10.1MB) 100%

|████████████████████████████████| 10.1MB 1.8MB/s

Requirement already satisfied: scipy>=0.14.0 in

./lib/python3.7/site-packages (from seaborn) (1.3.0)

Collecting matplotlib> = 1.4.3 (from seaborn)

Downloading

https://files.pythonhosted.org/packages/c3/8b/af9e0984f

5c0df06d3fab0bf396eb09cbf05f8452de4e9502b182f59c33b/

matplotlib-3.1.1-cp37-cp37m-macosx_10_6_intel.

macosx_10_9_intel.macosx_10_9_x86_64

.macosx_10_10_intel.macosx_10_10_x86_64.whl (14.4MB) 100%

|████████████████████████████████| 14.4MB 1.4MB/s

………………………………..

………………………………..

Successfully installed cycler-0.10.0 kiwisolver-1.1.0

matplotlib-3.1.1 pandas-0.25.0 pyparsing-2.4.2

python-dateutil-2.8.0 pytz-2019.2 seaborn-0.9.0

Keras Installation Using Python

As of now, we have completed basic requirements for the installtion of Kera. Now, install the Keras using same procedure as specified below −

pip install keras

Quit virtual environment

After finishing all your changes in your project, then simply run the below command to quit the environment −

deactivate

Anaconda Cloud

We believe that you have installed anaconda cloud on your machine. If anaconda is not installed, then visit the official link, www.anaconda.com/distribution and choose download based on your OS.

Create a new conda environment

Launch anaconda prompt, this will open base Anaconda environment. Let us create a new conda environment. This process is similar to virtualenv. Type the below command in your conda terminal −

conda create –name PythonCPU

If you want, you can create and install modules using GPU also. In this tutorial, we follow CPU instructions.

Activate conda environment

To activate the environment, use the below command −

activate PythonCPU

Install spyder

Spyder is an IDE for executing python applications. Let us install this IDE in our conda environment using the below command −

conda install spyder

Install python libraries

We have already known the python libraries numpy, pandas, etc., needed for keras. You can install all the modules by using the below syntax −

Syntax

conda install -c anaconda <module-name>

For example, you want to install pandas −

conda install -c anaconda pandas

Like the same method, try it yourself to install the remaining modules.

Install Keras

Now, everything looks good so you can start keras installation using the below command −

conda install -c anaconda keras

Launch spyder

Finally, launch spyder in your conda terminal using the below command −

spyder

To ensure everything was installed correctly, import all the modules, it will add everything and if anything went wrong, you will get module not found error message.

So, this brings us to the end of blog. This Tecklearn ‘Overview of Deep Learning Library Keras and How to install Keras Library on your machine’ blog helps you with commonly asked questions if you are looking out for a job in Artificial Intelligence. If you wish to learn Artificial Intelligence and build a career in AI or Machine Learning domain, then check out our interactive, Artificial Intelligence and Deep Learning with TensorFlow Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/artificial-intelligence-and-deep-learning-with-tensorflow/

Artificial Intelligence and Deep Learning with TensorFlow Training

About the Course

Tecklearn’s Artificial Intelligence and Deep Learning with Tensor Flow course is curated by industry professionals as per the industry requirements & demands and aligned with the latest best practices. You’ll master convolutional neural networks (CNN), TensorFlow, TensorFlow code, transfer learning, graph visualization, recurrent neural networks (RNN), Deep Learning libraries, GPU in Deep Learning, Keras and TFLearn APIs, backpropagation, and hyperparameters via hands-on projects. The trainee will learn AI by mastering natural language processing, deep neural networks, predictive analytics, reinforcement learning, and more programming languages needed to shine in this field.

Why Should you take Artificial Intelligence and Deep Learning with Tensor Flow Training?

  • According to Paysa.com, an Artificial Intelligence Engineer earns an average of $171,715, ranging from $124,542 at the 25th percentile to $201,853 at the 75th percentile, with top earners earning more than $257,530.
  • Worldwide Spending on Artificial Intelligence Systems Will Be Nearly $98 Billion in 2023, According to New IDC Spending Guide at a GACR of 28.5%.
  • IBM, Amazon, Apple, Google, Facebook, Microsoft, Oracle and almost all the leading companies are working on Artificial Intelligence to innovate future technologies.

What you will Learn in this Course?

Introduction to Deep Learning and AI

  • What is Deep Learning?
  • Advantage of Deep Learning over Machine learning
  • Real-Life use cases of Deep Learning
  • Review of Machine Learning: Regression, Classification, Clustering, Reinforcement Learning, Underfitting and Overfitting, Optimization
  • Pre-requisites for AI & DL
  • Python Programming Language
  • Installation & IDE

Environment Set Up and Essentials

  • Installation
  • Python – NumPy
  • Python for Data Science and AI
  • Python Language Essentials
  • Python Libraries – Numpy and Pandas
  • Numpy for Mathematical Computing

More Prerequisites for Deep Learning and AI

  • Pandas for Data Analysis
  • Machine Learning Basic Concepts
  • Normalization
  • Data Set
  • Machine Learning Concepts
  • Regression
  • Logistic Regression
  • SVM – Support Vector Machines
  • Decision Trees
  • Python Libraries for Data Science and AI

Introduction to Neural Networks

  • Creating Module
  • Neural Network Equation
  • Sigmoid Function
  • Multi-layered perception
  • Weights, Biases
  • Activation Functions
  • Gradient Decent or Error function
  • Epoch, Forward & backword propagation
  • What is TensorFlow?
  • TensorFlow code-basics
  • Graph Visualization
  • Constants, Placeholders, Variables

Multi-layered Neural Networks

  • Error Back propagation issues
  • Drop outs

Regularization techniques in Deep Learning

Deep Learning Libraries

  • Tensorflow
  • Keras
  • OpenCV
  • SkImage
  • PIL

Building of Simple Neural Network from Scratch from Simple Equation

  • Training the model

Dual Equation Neural Network

  • TensorFlow
  • Predicting Algorithm

Introduction to Keras API

  • Define Keras
  • How to compose Models in Keras
  • Sequential Composition
  • Functional Composition
  • Predefined Neural Network Layers
  • What is Batch Normalization
  • Saving and Loading a model with Keras
  • Customizing the Training Process
  • Using TensorBoard with Keras
  • Use-Case Implementation with Keras

GPU in Deep Learning

  • Introduction to GPUs and how they differ from CPUs
  • Importance of GPUs in training Deep Learning Networks
  • The GPU constituent with simpler core and concurrent hardware
  • Keras Model Saving and Reusing
  • Deploying Keras with TensorBoard

Keras Cat Vs Dog Modelling

  • Activation Functions in Neural Network

Optimization Techniques

  • Some Examples for Neural Network

Convolutional Neural Networks (CNN)

  • Introduction to CNNs
  • CNNs Application
  • Architecture of a CNN
  • Convolution and Pooling layers in a CNN
  • Understanding and Visualizing a CNN

RNN: Recurrent Neural Networks

  • Introduction to RNN Model
  • Application use cases of RNN
  • Modelling sequences
  • Training RNNs with Backpropagation
  • Long Short-Term memory (LSTM)
  • Recursive Neural Tensor Network Theory
  • Recurrent Neural Network Model

Application of Deep Learning in image recognition, NLP and more

Real world projects in recommender systems and others

Got a question for us? Please mention it in the comments section and we will get back to you.

 

 

0 responses on "Overview of Deep Learning Library Keras and How to install Keras Library on your machine"

Leave a Message

Your email address will not be published. Required fields are marked *