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
Free Learning
Arrow right icon
TensorFlow 1.x Deep Learning Cookbook
TensorFlow 1.x Deep Learning Cookbook

TensorFlow 1.x Deep Learning Cookbook: Over 90 unique recipes to solve artificial-intelligence driven problems with Python

eBook
€20.98 €29.99
Paperback
€36.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

TensorFlow 1.x Deep Learning Cookbook

Regression

This chapter shows how regression can be done using TensorFlow. In this chapter, we will cover the following topics:

  • Choosing loss functions
  • Optimizers in TensorFlow
  • Reading from CSV files and preprocessing data
  • House price estimation-simple linear regression
  • House price estimation-multiple linear regression
  • Logistic regression on the MNIST dataset

Introduction

Regression is one of the oldest and yet quite powerful tools for mathematical modelling, classification, and prediction. Regression finds application in varied fields ranging from engineering, physical science, biology, and the financial market to social sciences. It is the basic tool in the hand of a data scientist.

Regression is normally the first algorithm that people in machine learning work with. It allows us to make predictions from data by learning the relationship between the dependent and independent variables. For example, in the case of house price estimation, we determine the relationship between the area of the house (independent variable) and its price (dependent variable); this relationship can be then used to predict the price of any house given its area. We can have multiple independent variables impacting the dependent variable. Thus, there are two...

Choosing loss functions

As discussed earlier, in regression we define the loss function or objective function and the aim is to find the coefficients such that the loss is minimized. In this recipe, you will learn how to define loss functions in TensorFlow and choose a proper loss function depending on the problem at hand.

Getting ready

Declaring a loss function requires defining the coefficients as variables and the dataset as placeholders. One can have a constant learning rate or changing learning rate and regularization constant. In the following code, let m be the number of samples, n the number of features, and P the number of classes. We should define these global parameters before the code:

m = 1000
n = 15
P = 2
...

Optimizers in TensorFlow

From your high school math, you must know that a function's first derivative is zero at its maxima and minima. The gradient descent algorithm is based on the same principle--the coefficients (weights and biases) are adjusted such that the gradient of the loss function decreases. In regression, we use gradient descent to optimize the loss function and obtain coefficients. In this recipe, you will learn how to use the gradient descent optimizer of TensorFlow and some of its variants.

Getting ready

The update of coefficients (W and b) is done proportionally to the negative of the gradient of the loss function. There are three variations of gradient descent depending on the size of the training sample...

Reading from CSV files and preprocessing data

Most of you will already be familiar with Pandas and its usefulness in handling large dataset files. TensorFlow also offers methods to read from the files. In the first chapter, we went through the recipe for reading from files in TensorFlow; in this recipe, we will focus on how to read from CSV files and preprocess the data before training.

Getting ready

We will consider the Boston housing price dataset (http://lib.stat.cmu.edu/datasets/boston) collected by Harrison and Rubinfield in 1978. The dataset contains 506 sample cases. Each house is assigned 14 attributes:

  • CRIM: per capita crime rate by town
  • ZN: Proportion of residential land zoned for lots over 25,000 sq.ft
  • INDUS: Proportion...

House price estimation-simple linear regression

In this recipe, we will perform simple linear regression based on the number of rooms (RM) on the Boston house price dataset.

Getting ready

Our goal is to predict the house price given in the last column (MEDV). In this recipe, we load the dataset from the TensorFlow Contrib dataset directly. We optimize the coefficients for an individual training sample using the stochastic gradient descent optimizer.

How to do it...

We proceed with the recipe as follows:

  1. The first step is to import all the packages that we will need:
...

House price estimation-multiple linear regression

We can do multiple linear regression on the same data by making a slight modification in the declaration of weights and placeholders. In the case of multiple linear regression, as each feature has different value ranges, normalization becomes essential. Here is the code for multiple linear regression on the Boston house price dataset, using all the 13 input features.

How to do it...

Here is how we proceed with the recipe:

  1. The first step is to import all the packages that we will need:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
  1. We need to normalize the feature data since the data ranges of all the features are varied. We define a normalize...

Logistic regression on the MNIST dataset

This recipe is based on the logistic regressor for MNIST provided at https://www.tensorflow.org/get_started/mnist/beginners, but we will add some TensorBoard summaries to understand it better. Most of you must already be familiar with the MNIST dataset--it is like the ABC of machine learning. It contains images of handwritten digits and a label for each image, saying which digit it is.

For logistic regression, we use one-hot encoding for the output Y. Thus, we have 10 bits representing the output; each bit can have a value either 0 or 1, and being one-hot means that for each image in label Y, only one bit out of the 10 will have value 1, the rest will be zeros. Here, you can see the image of the handwritten numeral 8, along with its hot encoded value [0 0 0 0 0 0 0 0 1 0]:

...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Skill up and implement tricky neural networks using Google's TensorFlow 1.x
  • An easy-to-follow guide that lets you explore reinforcement learning, GANs, autoencoders, multilayer perceptrons and more.
  • Hands-on recipes to work with Tensorflow on desktop, mobile, and cloud environment

Description

Deep neural networks (DNNs) have achieved a lot of success in the field of computer vision, speech recognition, and natural language processing. This exciting recipe-based guide will take you from the realm of DNN theory to implementing them practically to solve real-life problems in the artificial intelligence domain. In this book, you will learn how to efficiently use TensorFlow, Google’s open source framework for deep learning. You will implement different deep learning networks, such as Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), Deep Q-learning Networks (DQNs), and Generative Adversarial Networks (GANs), with easy-to-follow standalone recipes. You will learn how to use TensorFlow with Keras as the backend. You will learn how different DNNs perform on some popularly used datasets, such as MNIST, CIFAR-10, and Youtube8m. You will not only learn about the different mobile and embedded platforms supported by TensorFlow, but also how to set up cloud platforms for deep learning applications. You will also get a sneak peek at TPU architecture and how it will affect the future of DNNs. By using crisp, no-nonsense recipes, you will become an expert in implementing deep learning techniques in growing real-world applications and research areas such as reinforcement learning, GANs, and autoencoders.

Who is this book for?

This book is intended for data analysts, data scientists, machine learning practitioners and deep learning enthusiasts who want to perform deep learning tasks on a regular basis and are looking for a handy guide they can refer to. People who are slightly familiar with neural networks, and now want to gain expertise in working with different types of neural networks and datasets, will find this book quite useful.

What you will learn

  • • Leverage different data sets such as MNIST, CIFAR-10, and Youtube8m with TensorFlow and learn how to access and use them in your code
  • • Use TensorBoard to understand neural network architectures, optimize the learning process, and peek inside the neural network black box
  • • Use different regression techniques for prediction and classifi cation problems
  • • Build single and multilayer perceptrons in TensorFlow
  • • Implement a CNN and a RNN in TensorFlow, and use them to solve real-world problems
  • • Learn how Restricted Boltzmann Machines can be used to recommend movies
  • • Understand the implementation of autoencoders and deep belief networks, and use them for emotion detection
  • • Master the different reinforcement learning methods in order to implement game playing agents

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 12, 2017
Length: 536 pages
Edition : 1st
Language : English
ISBN-13 : 9781788291866
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 : Dec 12, 2017
Length: 536 pages
Edition : 1st
Language : English
ISBN-13 : 9781788291866
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 99.97
TensorFlow 1.x Deep Learning Cookbook
€36.99
Mastering TensorFlow 1.x
€29.99
Neural Network Programming with TensorFlow
€32.99
Total 99.97 Stars icon
Banner background image

Table of Contents

14 Chapters
TensorFlow - An Introduction Chevron down icon Chevron up icon
Regression Chevron down icon Chevron up icon
Neural Networks - Perceptron Chevron down icon Chevron up icon
Convolutional Neural Networks Chevron down icon Chevron up icon
Advanced Convolutional Neural Networks Chevron down icon Chevron up icon
Recurrent Neural Networks Chevron down icon Chevron up icon
Unsupervised Learning Chevron down icon Chevron up icon
Autoencoders Chevron down icon Chevron up icon
Reinforcement Learning Chevron down icon Chevron up icon
Mobile Computation Chevron down icon Chevron up icon
Generative Models and CapsNet Chevron down icon Chevron up icon
Distributed TensorFlow and Cloud Deep Learning Chevron down icon Chevron up icon
Learning to Learn with AutoML (Meta-Learning) Chevron down icon Chevron up icon
TensorFlow Processing Units 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.4
(16 Ratings)
5 star 50%
4 star 6.3%
3 star 12.5%
2 star 0%
1 star 31.3%
Filter icon Filter
Top Reviews

Filter reviews by




NSingh Jan 15, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Without using complicated maths, authors have very meticulously implemented deep neural networks.The book is not for novices; instead, it is for advanced users. You will make most of the book if you:1. Are advanced Python users and looking to build an understanding of Deep Neural Networks. OR2. Know deep learning, and want to shift to TensorFlow for your work.The recipes use standard datasets already built into TensorFlow library, and this allows one to focus on implementation details of the model.I especially liked the chapter on Autoencoders as it very exhaustively covered the implementation of different types of Autoencoders on the same dataset allowing me to compare their performance. The chapter on Reinforcement learning was refreshingly simple, I could copy the recipe and with little modification had my policy gradient model working in the different game environment in no time.The book also gives step by step instruction on how to use Tensorflow models for mobile apps both on IOS and Android.The USP of the book is that it covers almost all DL models starting from the basic MLP to the recently released CAPSNet. Another great thing about the book is that it has given the references to the research papers it has implemented. The hands-on approach of the book makes it a useful reference for research.For codes, I would suggest you use the GitHub link provided in the book.Overall it is a great book.
Amazon Verified review Amazon
Juan Lopez Feb 05, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Even for a good chef a recipe book always come handy, and thanks to the authors all Deep Learning professionals, enthusiasts, or beginners will have this Cookbook for consulting. From simple Linear Regressions to Generative Adversarial Networks you will find easy recipes to follow and learn how to implement all these kind of networks.
Amazon Verified review Amazon
Gayan Aug 18, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good product good read
Amazon Verified review Amazon
Kishore A Feb 16, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book gives a very good overview of the various algorithms to get one started in deep learning. I have especially liked the fact that it walks the reader through multiple use cases across all the algorithms. Additionally, it has a broad coverage including CNN, RNN, RL, Auto encoders, Capsule networks and even the implementation of tensorflow on mobile devices.Definitely a great buy!
Amazon Verified review Amazon
A. Jaokar Jan 11, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I bought this book (physical copy) from the Packt based on reading the author's previous book(on Keras). I have enjoyed the previous book and use it extensively because of its practical implementation approach. The same is followed here (but for core tensorflow instead of Keras). The cookbook approach helps a lot for tensorflow. Apart from CNNs, RNNS etc the book also covers Tensorflow mobile (which is of interest for me personally). The section on distributed tensorflow(Chapter 12) was new and interesting for me. Like in the first book, I referred to the author's git repo which I found useful. I used this book mainly to get a deeper understanding of tensorflow(I was starting from keras). It is also a good approach to learning tensorflow itself because of the cookbook approach. It even talks of Capsule networks. Hence, at the time of review(Jan 18) - its as current as Tensorflow can be. The distributed tensorflow also covers Azure and Amazon in addition to Google cloud(was nice to see the open approach). finally, I suggest that future versions of the book could expand on TPUs(also an interest for me based on my work)
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.