Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Keras Deep Learning Cookbook

You're reading from  Keras Deep Learning Cookbook

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781788621755
Pages 252 pages
Edition 1st Edition
Languages
Authors (3):
Rajdeep Dua Rajdeep Dua
Profile icon Rajdeep Dua
Sujit Pal Sujit Pal
Profile icon Sujit Pal
Manpreet Singh Ghotra Manpreet Singh Ghotra
Profile icon Manpreet Singh Ghotra
View More author details
Toc

Table of Contents (17) Chapters close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Keras Installation 2. Working with Keras Datasets and Models 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 1. Other Books You May Enjoy Index

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

Install the latest version of the Docker CLI from https://docs.docker.com/engine/installation/.

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 IDIMAGE COMMANDCREATED STATUS PORTS NAMES
45998a5eea89rajdeepd/jupyter-keras"tini -- start-not..." About an hour ago Up About an hour 0.0.0.0:8888->8888/tcpadmiring_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.

You have been reading a chapter from
Keras Deep Learning Cookbook
Published in: Oct 2018 Publisher: Packt ISBN-13: 9781788621755
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 ₹800/month. Cancel anytime