Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Deep Learning with Keras
Deep Learning with Keras

Deep Learning with Keras: Implementing deep learning models and neural networks with the power of Python

Arrow left icon
Profile Icon Antonio Gulli Profile Icon Sujit Pal
Arrow right icon
€8.99 €32.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (20 Ratings)
eBook Apr 2017 318 pages 1st Edition
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Antonio Gulli Profile Icon Sujit Pal
Arrow right icon
€8.99 €32.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (20 Ratings)
eBook Apr 2017 318 pages 1st Edition
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Deep Learning with Keras

Keras Installation and API

In the previous chapter, we discussed the basic principles of neural networks and provided a few examples of nets that are able to recognize MNIST handwritten numbers.

This chapter explains how to install Keras, Theano, and TensorFlow. Step by step, we will look at how to get the environment working and move from intuition to working nets in very little time. Then we will discuss how to install on a dockerized infrastructure based on containers, and in the cloud with Google GCP, Amazon AWS, and Microsoft Azure. In addition to that, we will present an overview of Keras APIs, and some commonly useful operations such as loading and saving neural networks' architectures and weights, early stopping, history saving, checkpointing, and interactions with TensorBoard and Quiver. Let us start.

By the end of this chapter, we will have covered the following topics:

  • Installing and configuring...

Installing Keras

In the sections to follow, we will show how to install Keras on multiple platforms.

Step 1 — install some useful dependencies

First, we install the numpy package, which provides support for large, multidimensional arrays and matrices as well as high-level mathematical functions. Then we install scipy, a library used for scientific computation. After that, it might be appropriate to install scikit-learn, a package considered the Python Swiss army knife for machine learning. In this case, we will use it for data exploration. Optionally, it could be useful to install pillow, a library useful for image processing, and h5py, a library useful for data serialization used by Keras for model saving. A single command line is enough for installing...

Configuring Keras

Keras has a very minimalist configuration file. Let's load it with a vi session. The parameters are very simple:

Parameters Values
image_dim_ordering Can be either tf for the TensorFlow image ordering or th for Theano image ordering
epsilon The epsilon value used during computation
floatx Can be either float32 or float64
backend Can be either tensorflow or theano

The image_dim_ordering of th value gives you a somewhat non-intuitive dimension ordering for images (depth, width, and height), instead of (width, height, and depth), for tf. The following are the default parameters in my machine:

If you install a GPU-enabled TensorFlow version, then Keras will automatically use your configured GPU when TensorFlow is selected as the backend.

Installing Keras on Docker

One of the easiest ways to get started with TensorFlow and Keras is running in a Docker container. A convenient solution is to use a predefined Docker image for deep learning created by the community that contains all the popular DL frameworks (TensorFlow, Theano, Torch, Caffe, and so on). Refer to the GitHub repository at https://github.com/saiprashanths/dl-docker for the code files. Assuming that you already have Docker up and running (for more information, refer to https://www.docker.com/products/overview), installing it is pretty simple and is shown as follows:

The following screenshot, says something like, after getting the image from Git, we build the Docker image:

In this screenshot, we see how to run it:

From within the container, it is possible to activate support for Jupyter Notebooks (for more information, refer to http://jupyter.org/):

Access it directly...

Installing Keras on Google Cloud ML

Installing Keras on Google Cloud is very simple. First, we can install Google Cloud (for the downloadable file, refer to https://cloud.google.com/sdk/), a command-line interface for Google Cloud Platform; then we can use CloudML, a managed service that enables us to easily build machine, learning models with TensorFlow. Before using Keras, let's use Google Cloud with TensorFlow to train an MNIST example available on GitHub. The code is local and training happens in the cloud:

In the following screenshot, you can see how to run a training session:

We can use TensorBoard to show how cross-entropy decreases across iterations:

In the next screenshot, we see the graph of cross-entropy:

Now, if we want to use Keras on the top of TensorFlow, we simply download the Keras source from PyPI (for the downloadable file, refer to https://pypi.Python.org/pypi...

Installing Keras on Amazon AWS

Installing TensorFlow and Keras on Amazon is very simple. Indeed, it is possible to use a prebuilt AMI named TFAMI.v3 that is open and free (for more information, refer to https://github.com/ritchieng/tensorflow-aws-ami), shown as follows:

This AMI runs TensorFlow in less than five minutes and supports TensorFlow, Keras, OpenAI Gym, and all dependencies. As of January 2017, it supports the following:

  • TensorFlow 0.12
  • Keras 1.1.0
  • TensorLayer 1.2.7
  • CUDA 8.0
  • CuDNN 5.1
  • Python 2.7
  • Ubuntu 16.04

In addition, TFAMI.v3 works on P2 computing instances (for more information, refer to https://aws.amazon.com/ec2/instance-types/#p2), as shown in the following screenshot:

Some features of P2 instances are as follows:

  • Intel Xeon E5-2686v4 (Broadwell) processors
  • NVIDIA K80 GPUs, each with 2,496 parallel cores and 12 GB of GPU memory
  • Supports peer-to-peer GPU communication
  • Provides...

Installing Keras on Microsoft Azure

One way to install Keras on Azure is to install the support for Docker and then get a containerized version of TensorFlow plus Keras. Online, it is also possible to find a detailed set of instructions on how to install Keras and TensorFlow with Docker, but this is essentially what we have seen already in a previous section (for more information, refer to https://blogs.msdn.microsoft.com/uk_faculty_connection/2016/09/26/tensorflow-on-docker-with-microsoft-azure/).

If you use Theano as the only backend, then Keras can run with just a click by loading a pre-built package available on Cortana Intelligence Gallery (for more information, refer to https://gallery.cortanaintelligence.com/Experiment/Theano-Keras-1).
The following sample shows how to import Theano and Keras into Azure ML directly as a ZIP file and use them in the Execute Python Script module. This example is due to...

Installing Keras


In the sections to follow, we will show how to install Keras on multiple platforms.

Step 1 — install some useful dependencies

First, we install the numpy package, which provides support for large, multidimensional arrays and matrices as well as high-level mathematical functions. Then we install scipy, a library used for scientific computation. After that, it might be appropriate to install scikit-learn, a package considered the Python Swiss army knife for machine learning. In this case, we will use it for data exploration. Optionally, it could be useful to install pillow, a library useful for image processing, and h5py, a library useful for data serialization used by Keras for model saving. A single command line is enough for installing what is needed. Alternatively, one can install Anaconda Python, which will automatically install numpy, scipy, scikit-learn, h5py, pillow, and a lot of other libraries that are needed for scientific computing (for more information, refer to...

Configuring Keras


Keras has a very minimalist configuration file. Let's load it with a vi session. The parameters are very simple:

Parameters

Values

image_dim_ordering

Can be either tf for the TensorFlow image ordering or th for Theano image ordering

epsilon

The epsilon value used during computation

floatx

Can be either float32 or float64

backend

Can be either tensorflow or theano

The image_dim_ordering of th value gives you a somewhat non-intuitive dimension ordering for images (depth, width, and height), instead of (width, height, and depth), for tf. The following are the default parameters in my machine:

Note

If you install a GPU-enabled TensorFlow version, then Keras will automatically use your configured GPU when TensorFlow is selected as the backend.

Installing Keras on Docker


One of the easiest ways to get started with TensorFlow and Keras is running in a Docker container. A convenient solution is to use a predefined Docker image for deep learning created by the community that contains all the popular DL frameworks (TensorFlow, Theano, Torch, Caffe, and so on). Refer to the GitHub repository at https://github.com/saiprashanths/dl-docker for the code files. Assuming that you already have Docker up and running (for more information, refer to https://www.docker.com/products/overview), installing it is pretty simple and is shown as follows:

The following screenshot, says something like, after getting the image from Git, we build the Docker image:

In this screenshot, we see how to run it:

From within the container, it is possible to activate support for Jupyter Notebooks (for more information, refer to http://jupyter.org/):

Access it directly from the host machine on port:

It is also possible to access TensorBoard (for more information, refer...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Implement various deep learning algorithms in Keras and see how deep learning can be used in games
  • See how various deep learning models and practical use-cases can be implemented using Keras
  • A practical, hands-on guide with real-world examples to give you a strong foundation in Keras

Description

This book starts by introducing you to supervised learning algorithms such as simple linear regression, the classical multilayer perceptron and more sophisticated deep convolutional networks. You will also explore image processing with recognition of handwritten digit images, classification of images into different categories, and advanced objects recognition with related image annotations. An example of identification of salient points for face detection is also provided. Next you will be introduced to Recurrent Networks, which are optimized for processing sequence data such as text, audio or time series. Following that, you will learn about unsupervised learning algorithms such as Autoencoders and the very popular Generative Adversarial Networks (GANs). You will also explore non-traditional uses of neural networks as Style Transfer. Finally, you will look at reinforcement learning and its application to AI game playing, another popular direction of research and application of neural networks.

Who is this book for?

If you are a data scientist with experience in machine learning or an AI programmer with some exposure to neural networks, you will find this book a useful entry point to deep-learning with Keras. A knowledge of Python is required for this book.

What you will learn

  • Optimize step-by-step functions on a large neural network using the Backpropagation algorithm
  • Fine-tune a neural network to improve the quality of results
  • Use deep learning for image and audio processing
  • Use Recursive Neural Tensor Networks (RNTNs) to outperform standard word embedding in special cases
  • Identify problems for which Recurrent Neural Network (RNN) solutions are suitable
  • Explore the process required to implement Autoencoders
  • Evolve a deep neural network using reinforcement learning

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 26, 2017
Length: 318 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129030
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 26, 2017
Length: 318 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129030
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 129.97
TensorFlow Machine Learning Cookbook
€45.99
Deep Learning with TensorFlow
€41.99
Deep Learning with Keras
€41.99
Total 129.97 Stars icon
Banner background image

Table of Contents

9 Chapters
Neural Networks Foundations Chevron down icon Chevron up icon
Keras Installation and API Chevron down icon Chevron up icon
Deep Learning with ConvNets Chevron down icon Chevron up icon
Generative Adversarial Networks and WaveNet Chevron down icon Chevron up icon
Word Embeddings Chevron down icon Chevron up icon
Recurrent Neural Network — RNN Chevron down icon Chevron up icon
Additional Deep Learning Models Chevron down icon Chevron up icon
AI Game Playing Chevron down icon Chevron up icon
Conclusion Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(20 Ratings)
5 star 25%
4 star 20%
3 star 35%
2 star 15%
1 star 5%
Filter icon Filter
Top Reviews

Filter reviews by




Kyle Mar 07, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Fast and convenient, no surprises.
Amazon Verified review Amazon
Amazon Customer Sep 07, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is definitely one of the best resources if you want to learn Keras.
Amazon Verified review Amazon
Arbaaz Qureshi Jun 23, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good book, for readers who are familiar with deep learning concepts and Keras and wish to improve them further. Correct the errors of the code section, in the next version.
Amazon Verified review Amazon
Tae S. Shin Dec 09, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I needed a reference book to use Keras that is a user-oriented library for easy modeling of neural networks in Python. Unlike some low reviews on the book, it turned out to be exactly what I expected and what its title said, Implementing deep learning models and neural networks with Keras in Python.If you want to know more about theory of deep learning, you should refer to other deep learning books. If you want to know how Keras API internally works, you may want to look at other books on Tensorflow or Theano that was low level API for Keras and with which you can define neural networks in node-level. But if you want to flexibly and easily build a NN model with fewer lines of code, this book might be good for you.
Amazon Verified review Amazon
Melvin Dec 30, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I felt compelled to write a review because I really think this is an exceptionally good book under the circumstances. When I say "under the circumstances", I mean given the fact that deep learning is a challenging topic to explain and requires both a theoretic and practical approach to be appreciated. The author clearly avoids getting bogged down with the theoretical aspects and I can appreciate why since a thorough theoretical understanding would require a separate book in it's own right.This book will not help you understand the theory or underlying mathematics. However, if you already understand the theory and want to learn to use a package like Keras then this is the book for you.This book stands out because it gives details about the implementation aspects of coding many different deep learning models that you will hear about in the literature and in the field. For example, LeNet, ResNet, etc. among many others are demonstrated through out the book.Generally speaking, topics in deep learning are not easy to explain to the average reader and I think the author recognizes this difficulty and chooses to place his focus on demonstrating how to implement deep learning methods and being careful to explain what the different modules do and their respective parameters.In my view, this book is very suitable for Data Scientists who already know the spectrum of machine learning models and techniques and want to get their hands dirty as fast as possible with deep learning. This book is a much better practical book for deep learning than the popular book by Aurélien Géron called "Hands-On Machine Learning with Scikit-Learn and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems". I have looked at many deep learning books and in my view this one did the best job is getting me comfortable with implementing deep learning models on my own.The one thing that I found the book was lacking is that it's final chapter on AI and reinforcement learning did not seem as thorough and detailed as the other chapters in the book. Having reviewed many books in the area of deep learning, I can honestly say this is probably the best book I have come across so far. However, I came to this book already having a solid understand of deep learning theory.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.