Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Keras Deep Learning Cookbook

You're reading from   Keras Deep Learning Cookbook Over 30 recipes for implementing deep neural networks in Python

Arrow left icon
Product type Paperback
Published in Oct 2018
Publisher Packt
ISBN-13 9781788621755
Length 252 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Sujit Pal Sujit Pal
Author Profile Icon Sujit Pal
Sujit Pal
Manpreet Singh Ghotra Manpreet Singh Ghotra
Author Profile Icon Manpreet Singh Ghotra
Manpreet Singh Ghotra
Rajdeep Dua Rajdeep Dua
Author Profile Icon Rajdeep Dua
Rajdeep Dua
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Keras Installation 2. Working with Keras Datasets and Models FREE CHAPTER 3. Data Preprocessing, Optimization, and Visualization 4. Classification Using Different Keras Layers 5. Implementing Convolutional Neural Networks 6. Generative Adversarial Networks 7. Recurrent Neural Networks 8. Natural Language Processing Using Keras Models 9. Text Summarization Using Keras Models 10. Reinforcement Learning 11. Other Books You May Enjoy

Installing Keras with Jupyter Notebook in a Docker image

In this recipe, we learn how to install and use a Docker container running Keras inside a container and access it using Jupyter.

Getting ready

How to do it...

In the following section, we will be learning how to install the Docker container.

Installing the Docker container 

  1. Execute the following command on the Terminal to run the container. The container image is available with the tag rajdeepd/jupyter-keras:
docker run -d -p 8888:8888 rajdeepd/jupyter-keras start-notebook.sh --NotebookApp.token=''
  1. This will install the Notebook locally and start it as well. You can execute the docker ps -a command and see the output in the Terminal, as follows:
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                         PORTS                     NAMES
45998a5eea89 rajdeepd/jupyter-keras "tini -- start-not..." About an hour ago Up About an hour 0.0.0.0:8888->8888/tcp admiring_wing

Please note that the host port of 8888 is mapped to the container port of 8888.

  1. Open the browser at the following URL http://localhost:8888:

You will notice that Jupyter is running. You can create a new Notebook and run Keras-specific code.

Installing the Docker container with the host volume mapped

In this section, we look at how to map the local volume $(pwd)/keras-samples to the work directory in the container.

  1. Execute the note -v flag command, which does the volume mapping:
docker run -d -v /$(pwd)/keras-samples:/home/jovyan/work \
-p 8888:8888 rajdeepd/jupyter-keras start-notebook.sh --NotebookApp.token=''

If you go to the URL, you will notice the sample page being displayed.

  1. If you got /$(pwd)/keras-samples, you will notice that the Notebooks are available in the host directory, and they also can be seen being loaded by Jupyter:
rdua1-ltm:keras-samples rdua$ pwd
/Users/rdua/personal/keras-samples
rdua1-ltm:keras-samples rdua$ ls
MNIST CNN.ipynb sample_one.ipynb

If you open MNIST CNN.ipynb, it is a Keras CNN sample, which we will learn more about in the subsequent chapters.

In this recipe, we used the Docker image rajdeepd/jupyter-keras to create a Keras environment and access it from Jupyter running in the host environment.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime