Deep learning to install Keras and its dependencies on Ubuntu

What is Keras

Keras is an open source artificial neural network library written in Python, which can be used as a high-level application program interface for Tensorflow, Microsoft-CNTK and Theano for the design, debugging, evaluation, application and visualization of deep learning models.

The main developer of Keras is Google engineer François Chollet, and its GitHub project page contains 6 main maintainers and more than 800 direct contributors. After the official version of Keras is released, except for some pre-compiled models, the source code is released under the MIT license.

Advantages of Keras##

**1. friendly user. **
Keras is an API designed for humans, not for machines.
It puts the user experience first and center. Keras follows best practices for reducing cognitive difficulties: it provides a consistent and simple API, minimizes the number of user actions required for common use cases, and provides clear and actionable feedback when user errors occur.

**2. Modularity. **
A model is understood as a sequence or diagram composed of independent, fully configurable modules.
These modules can be assembled with as few restrictions as possible. In particular, neural network layers, loss functions, optimizers, initialization methods, activation functions, and regularization methods are all modules that can be combined to build new models.

**3. Easy to expand. **
New modules are easy to add (as new classes and functions), and existing modules already provide plenty of examples. Keras is more suitable for advanced research because it can easily create new modules that can improve expressiveness.

**4. Based on Python. **
Keras does not have a separate configuration file in a specific format. The model is defined in Python code, which is compact, easy to debug, and easy to extend.

installation##

First install tensorflow

# GPU version
pip install --upgrade tensorflow-gpu

# CPU version
pip install --upgrade tensorflow

Verify that the installation is successful:

import tensorflow as tf

Then install keras

# Keras installation
pip install keras -U --pre

Install python scientific computing environment matplotlib

numpy

NumPy (Numerical Python) is an extension library of the Python language, which supports a large number of dimensional arrays and matrix operations, and also provides a large number of mathematical function libraries for array operations.

sudo apt-get install python-numpy

scipy

scipy is an advanced scientific computing library, the common ones are interpolation operations, optimization algorithms, image processing and mathematical statistics.

sudo apt-get install python-scipy

matplotlib

Matplotlib is a plotting library for Python. It can be used with NumPy and provides an effective open source alternative to MatLab. It can also be used with graphics toolkits such as PyQt and wxPython.

sudo apt-get install python-matplotlib

Install the BLAS library##

BLAS (Basic Linear Algebra Subprograms) is the basic linear algebra subprogram library, which contains a large number of programs about linear algebra operations that have been written.

sudo apt-get install build-essential cmake git unzip \
pkg-config libopenblas-dev liblapack-dev

Install HDF5

It was originally developed by NASA (National Aeronautics and Space Administration) to save large files of numerical data in an efficient binary format. It allows you to save Keras models to disk quickly and efficiently.

sudo apt-get install libhdf5-serial-dev python-h5py

Install Graphviz and pydot-ng

Used to visualize Keras models.

sudo apt-get install graphviz
sudo pip install pydot-ng

Install opencv

OpenCV is a cross-platform computer vision library released under the BSD license (open source), which can run on Linux, Windows, Android and Mac OS operating systems. It is lightweight and efficient—consisting of a series of C functions and a small number of C++ classes, it also provides interfaces to languages such as Python, Ruby, and MATLAB, and implements many common algorithms in image processing and computer vision.

sudo apt-get install python-opencv

Set GPU support##

Because I don’t have a GPU here, the following reference
GPU is not absolutely necessary, but books generally recommend using GPU.
Sometimes it may take several hours to run the trained model on the CPU, but only a few minutes on a good GPU.

If you want to use NVIDIA GPU for deep learning, you need to install CUDA and cuDNN at the same time.

CUDA

CUDA™ is a general-purpose parallel computing architecture launched by NVIDIA, which enables GPUs to solve complex computing problems.

download

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/
x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb

installation

sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/
cuda/repos/ubuntu1604/ x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda-8-0

cuDNN

NVIDIA cuDNN is a GPU accelerated library for deep neural networks. It emphasizes performance, ease of use and low memory overhead. NVIDIA cuDNN can be integrated into higher-level machine learning frameworks, such as Google's Tensorflow and the popular caffe software of the University of California, Berkeley.

When using cuDNN and running on the GPU, the training speed of the model can usually be increased by 50% to 100%

installation

  1. Sign up for a free NVIDIA developer account.
  2. Execute installation command
sudo dpkg -i dpkg -i libcudnn6*.deb

Ok, even if some basic tools are installed here. O(∩_∩)O

reference##

Keras Baidu EncyclopediaKeras official document NumPy TutorialNumPy Matplotlib

Recommended Posts

Deep learning to install Keras and its dependencies on Ubuntu
How to install theano and keras on ubuntu system
How to install Pycharm and Ipython on Ubuntu 16.04/18.04
How to install and configure NATS on Ubuntu 16.04
How to install and configure Gogs on Ubuntu 18.04
How to install and configure Cyberpanel on Ubuntu 18.04
How to install and secure phpMyAdmin on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure GitLab on Ubuntu 18.04
How to install and use Docker on Ubuntu 20.04
How to install and configure Ansible on Ubuntu 18.04
How to install and use Curl on Ubuntu 18.04
How to install and use Composer on Ubuntu 18.04
How to install and use Wine on Ubuntu 18.04
How to install and secure phpMyAdmin on Ubuntu 16.04
How to install and configure Elasticsearch on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
How to install and use Composer on Ubuntu 20.04
How to install and use BaasBox on Ubuntu 14.04
How to install and configure VNC on Ubuntu 18.04
How to install and configure Sphinx on Ubuntu 16.04
How to install and configure OrientDB on Ubuntu 14.04
How to install and use PostgreSQL on Ubuntu 16.04
How to install and configure AppScale on Ubuntu 12.04
How to install and use Docker on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
How to install and use MySQL Workbench on Ubuntu 18.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
Install and configure MySQL on Ubuntu
How to install Vagrant on Ubuntu 20.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04