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

Arrow left icon
Profile Icon Mike Bernico
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Mar 2018 272 pages 1st Edition
eBook
$24.99 $35.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Mike Bernico
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Mar 2018 272 pages 1st Edition
eBook
$24.99 $35.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$24.99 $35.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781788837996
Vendor :
Google
Category :
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Mar 09, 2018
Length: 272 pages
Edition : 1st
Language : English
ISBN-13 : 9781788837996
Vendor :
Google
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 131.97
Deep Learning Quick Reference
$43.99
TensorFlow: Powerful Predictive Analytics with TensorFlow
$43.99
Deep Learning By Example
$43.99
Total $ 131.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.