Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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 Quick Reference
Deep Learning Quick Reference

Deep Learning Quick Reference: Useful hacks for training and optimizing deep neural networks with TensorFlow and Keras

eBook
€17.99 €26.99
Paperback
€32.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 Quick Reference

Using Deep Learning to Solve Regression Problems

In this chapter, we will build a simple multilayer perceptron (MLP), which is a fancy name for a neural network with a single hidden layer, to solve a regression problem. Then we will go deeper with a deep neural network that has several hidden layers. Along the way, we will explore model performance and over fitting. So, let's get started!

We will cover the following topics in this chapter:

  • Regression analysis and deep neural networks
  • Using deep neural networks for regression
  • Building an MLP in Keras
  • Building a deep neural network in Keras
  • Saving and loading a trained Keras model

Regression analysis and deep neural networks

In classic regression analysis, we use a linear model to learn the relationship between a set of independent variables and a dependent variable. In finding this relationship, we expect to be able to predict the value of the dependent variable given the values of the independent variables.

A second important reason to do regression analysis is to understand the impact a single independent variable has on the dependent variable when all other independent variables are held constant. One of the great things about traditional multiple linear regression is the ceteris paribus property of linear models. We can interpret the impact a single independent variable has on the dependent variable without consideration to the other independent variable by using the learned weight associated with that independent variable. This type of interpretation...

Using deep neural networks for regression

Now that you hopefully understand why you would (and would not) want to use deep neural networks for regression, I'll show you how to do it. While it's not quite as simple as using linear regressor in scikit-learn, I think you'll find it quite easy using Keras. Most importantly, Keras will allow you to quickly iterate through model architectures without changing a lot of code.

How to plan a machine learning problem

When building a new neural network, I recommend following the same basic steps every time.

Deep neural networks can get very complicated, very quickly. A little bit of planning and organization and greatly accelerate your workflow!

The following are the steps...

Building an MLP in Keras

Keras uses an instance of a model object to contain a neural network. For those of you familiar with scikit-learn, this is probably quite familiar. What is somewhat different is that Keras models contain a set of layers. This set of layers needs to be defined by us. This allows for amazing flexibility in network architecture, with very little code.

Keras currently has two APIs for building models. In my examples, I'll be using the functional API. It's slightly more verbose but it allows additional flexibility. I'd recommend using the functional API whenever possible.

Our MLP will need an input layer, a hidden layer, and an output layer.

Input layer shape

Since we've already identified...

Building a deep neural network in Keras

Changing our model is as easy as redefining our previous build_network() function. Our input layer will stay the same because our input hasn't changed. Likewise, the output layer should remain the same.

I'm going to add parameters to our network by adding additional hidden layers. I hope that by adding these hidden layers, our network can learn more complicated relationships between the input and output. I am going to start by adding four additional hidden layers; the first three will have 32 neurons and the fourth will have 16. Here's what it will look like:

And here's the associated code for building the model in Keras:

def build_network(input_features=None):
inputs = Input(shape=(input_features,), name="input")
x = Dense(32, activation='relu', name="hidden1")(inputs)
x = Dense...

Saving and loading a trained Keras model

It's unlikely that you'll train a deep neural network and then apply it in the same script. Most likely, you will want to train your network and then save the structure and weights so that they can be used in a production-facing application designed to score new data. To do so, you'll need to be able to save and load your models.

Saving a model in Keras is very straightforward. You can use the model instance's .save() method to save the network structure and weights to an hdf5 file, as shown in the following code:

model.save("regression_model.h5")

That's really all there is to it. Loading a model from disk is just as simple. The code for doing this is given here for your reference:

from keras.models import load_model
model = load_model("regression_model.h5")

...

Summary

When you think about deep learning, you probably think about impressively complex computer vision problems, but deep neural networks can prove useful even for simple regression problems like this one. Hopefully, I've demonstrated that, while also introducing the Keras syntax and showing you how to build a very simple network.

As we continue, we will encounter much more complexity. Bigger networks, more complicated cost functions, and highly dimensional input data. However, the process I used in this chapter will remain same for the most part. In each case, we will outline the problem, identify the inputs and outputs, choose a cost function, create a network architecture, and finally train and tune our model.

Bias and variance can often be manipulated and reduced independently in deep neural networks if the following factors are taken care of:

  • Bias: This can be reduced...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • A quick reference to all important deep learning concepts and their implementations
  • Essential tips, tricks, and hacks to train a variety of deep learning models such as CNNs, RNNs, LSTMs, and more
  • Supplemented with essential mathematics and theory, every chapter provides best practices and safe choices for training and fine-tuning your models in Keras and Tensorflow.

Description

Deep learning has become an essential necessity to enter the world of artificial intelligence. With this book deep learning techniques will become more accessible, practical, and relevant to practicing data scientists. It moves deep learning from academia to the real world through practical examples. You will learn how Tensor Board is used to monitor the training of deep neural networks and solve binary classification problems using deep learning. Readers will then learn to optimize hyperparameters in their deep learning models. The book then takes the readers through the practical implementation of training CNN's, RNN's, and LSTM's with word embeddings and seq2seq models from scratch. Later the book explores advanced topics such as Deep Q Network to solve an autonomous agent problem and how to use two adversarial networks to generate artificial images that appear real. For implementation purposes, we look at popular Python-based deep learning frameworks such as Keras and Tensorflow, Each chapter provides best practices and safe choices to help readers make the right decision while training deep neural networks. By the end of this book, you will be able to solve real-world problems quickly with deep neural networks.

Who is this book for?

If you are a Data Scientist or a Machine Learning expert, then this book is a very useful read in training your advanced machine learning and deep learning models. You can also refer this book if you are stuck in-between the neural network modeling and need immediate assistance in getting accomplishing the task smoothly. Some prior knowledge of Python and tight hold on the basics of machine learning is required.

What you will learn

  • Solve regression and classification challenges with TensorFlow and Keras
  • Learn to use Tensor Board for monitoring neural networks and its training
  • Optimize hyperparameters and safe choices/best practices
  • Build CNN s, RNN s, and LSTM s and using word embedding from scratch
  • Build and train seq2seq models for machine translation and chat applications.
  • Understanding Deep Q networks and how to use one to solve an autonomous agent problem.
  • Explore Deep Q Network and address autonomous agent challenges.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 09, 2018
Length: 272 pages
Edition : 1st
Language : English
ISBN-13 : 9781788838917
Vendor :
Google
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 : Mar 09, 2018
Length: 272 pages
Edition : 1st
Language : English
ISBN-13 : 9781788838917
Vendor :
Google
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 98.97
Deep Learning Quick Reference
€32.99
TensorFlow: Powerful Predictive Analytics with TensorFlow
€32.99
Deep Learning By Example
€32.99
Total 98.97 Stars icon

Table of Contents

14 Chapters
The Building Blocks of Deep Learning Chevron down icon Chevron up icon
Using Deep Learning to Solve Regression Problems Chevron down icon Chevron up icon
Monitoring Network Training Using TensorBoard Chevron down icon Chevron up icon
Using Deep Learning to Solve Binary Classification Problems Chevron down icon Chevron up icon
Using Keras to Solve Multiclass Classification Problems Chevron down icon Chevron up icon
Hyperparameter Optimization Chevron down icon Chevron up icon
Training a CNN from Scratch Chevron down icon Chevron up icon
Transfer Learning with Pretrained CNNs Chevron down icon Chevron up icon
Training an RNN from scratch Chevron down icon Chevron up icon
Training LSTMs with Word Embeddings from Scratch Chevron down icon Chevron up icon
Training Seq2Seq Models Chevron down icon Chevron up icon
Using Deep Reinforcement Learning Chevron down icon Chevron up icon
Generative Adversarial Networks Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(6 Ratings)
5 star 83.3%
4 star 0%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Sara May 21, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I found this book to be one of the more comprehensive but still easily 'readable' texts on practical application of deep learning techniques. The project and code examples are practical, and display a variety of useful deep learning techniques. This will be a book I will likely reference again and again for tips and reminders as I work on deep learning projects both at work and in hobby coding.While there are a lot of exciting ideas and usecases presented in the book, the one I found most useful was one of the more 'humble' ideas, at least mathematically speaking... I really appreciated the deep dive into TensorBoard, and showing some really useful things to do with that particular tool. It showed some things that aren't always necessarily obvious to do from the documentation. The information presented will help make TensorBoard a much more prominent tool in my deep learning development process than it has been so far.
Amazon Verified review Amazon
Ms. One More Time Aug 06, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Love all the code in the book. Almost every bit of it worked without bugs. Almost every book of this type I have read had weak code that was often broken. This book was ten stars in this area.The level of text details was just perfect for me. I am past the beginner stage but not by much. I now feel after reading and running I can venture into kaggle datasets using Keras.I really loved learning about Tensorboard. It really helps me see if my model is too stupid or a real over fitter.
Amazon Verified review Amazon
Shannon Apr 20, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book has really accelerated my education in deep learning with a wide range of case studies that helped me understand how and when to use different deep learning solutions. It comes with a great git repo with the code for each chapter, so I could follow the code along with the text. I’ve taken deep learning MOOCs where I implemented neural networks in numpy and spent a lot of time on the math and theory, but this book has a variety of practical examples that make this topic a lot more accessible.A nice constant in this book is that it stays at a high level, but provides great references along the way if I want to take a deeper dive into a topic later on. This helped me stay focused to start implementing code, rather than diving into complex theories and sending me into endless Wikipedia loops.The author has a really approachable voice; he explains things clearly with humor and without condescension. I am particularly excited to use this book’s example on LSTMs to build a predictive model on cryptocurrency pricing to make better trading decisions!
Amazon Verified review Amazon
muuh Mar 16, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I am interested in applying machine learning and deep learning in practice, not so much in learning the details of the math and writing all the algorithms from scratch myself. I have taken various online courses from Coursera, Udemy, etc. Those tend to go either into the math at a level I am not interested in, or scratch the surface with very basic examples.This book provides foundations to understand what the different types of models (LSTM, CNN, MLP) are based on, and illustrates each with various realistic case studies and models, along with explanations. For me this provided a great way to get the overall idea, build and understanding, and apply the models to my data and problems. Sometimes I did go looking for a bit more in-depth understanding on how each model works, but the explanations in this book are the ones that enabled me to do that.Also having all the code available (and working) on Github is great for quick reference. Just have to remember to look for "deep learning reference github", and can quickly find myself a reminder on how to write some specific code.
Amazon Verified review Amazon
Winston Li Apr 20, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have an ebook version of this book, which I very much enjoyed reading. First of all, I really appreciate the author’s effort in nicely and properly formatting the equations and code snippets so that they are reader-friendly on kindle e-readers. It’s usually difficult to find a math/programming related ebook formatted well.As an analytics professional, I like the breadth of the book which covers almost all important types of deep learning frameworks and the usecases of each one. It does not focus only on Deep Learning, but also gives great overviews of more general backgrounds, such as time series for recurrent neural networks and NLP for LSTM/seq2seq models. The reader will have a full picture of the fields without losing the main concentration on Deep Learning. At the same time, the book keeps the depth of the content at the right amount so that the reader can quickly grasp the concept but also have sufficient math to get started with implementation and see how things play out. In addition, the book goes gradually from simple but foundational blocks to advanced models, which I find very easy to digest despite of the complexity of most the advanced topics.This book is a great starting point for people who are familiar with programming and some basic machine learning concepts, but want to know more about deep learning, especially what the state of the art looks like. It is also a good reference book for professionals who are familiar with the concepts but want to double check on how Deep Learning frameworks are set up in Tensorflow or Keras. The book comes with a lot of code examples, and also complete data and tutorial code downloadable through github. I personally like the fact that the book also covers how to locally set up GPU for deep learning, which is such an important topic yet a lot of deep learning books easily skip.
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.