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
TensorFlow Machine Learning Cookbook
TensorFlow Machine Learning Cookbook

TensorFlow Machine Learning Cookbook: Over 60 recipes to build intelligent machine learning systems with the power of Python , Second Edition

Arrow left icon
Profile Icon Nick McClure Profile Icon Sujit Pal
Arrow right icon
$20.98 $29.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (3 Ratings)
eBook Aug 2018 422 pages 2nd Edition
eBook
$20.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Nick McClure Profile Icon Sujit Pal
Arrow right icon
$20.98 $29.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (3 Ratings)
eBook Aug 2018 422 pages 2nd Edition
eBook
$20.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$20.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.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 Machine Learning Cookbook

The TensorFlow Way

In this chapter, we will introduce the key components of how TensorFlow operates. Then, we will tie it together to create a simple classifier and evaluate the outcomes. By the end of the chapter, you should have learned about the following:

  • Operations in a computational graph
  • Layering nested operations
  • Working with multiple layers
  • Implementing loss functions
  • Implementing backpropagation
  • Working with batch and stochastic training
  • Combining everything together
  • Evaluating models

Introduction

Now that we have introduced how TensorFlow creates tensors, and uses variables and placeholders, we will introduce how to act on these objects in a computational graph. From this, we can set up a simple classifier and see how well it performs.

Also, remember that the current and updated code from this book is available online on GitHub at https://github.com/nfmcclure/tensorflow_cookbook.

Operations in a computational graph

Now that we can put objects into our computational graph, we will introduce operations that act on such objects.

Getting ready

To start a graph, we load TensorFlow and create a session, as follows:

import tensorflow as tf 
sess = tf.Session() 

How to do it...

In this example, we will combine what we have learned and feed each number in a list into an operation in a graph and print the output:

First, we declare our tensors and placeholders. Here, we will create a NumPy array to feed into our operation:

import numpy as np 
x_vals = np...

Layering nested operations

In this recipe, we will learn how to put multiple operations on the same computational graph.

Getting ready

It's important to know how to chain operations together. This will set up layered operations in the computational graph. For a demonstration, we will multiply a placeholder by two matrices and then perform addition. We will feed in two matrices in the form of a three-dimensional NumPy array:

import tensorflow as tf 
sess = tf.Session() 

How to do it...

It is also important to note how the data will change shape as it passes through...

Working with multiple layers

Now that we have covered multiple operations, we will cover how to connect various layers that have data propagating through them.

Getting ready

In this recipe, we will introduce how to best connect various layers, including custom layers. The data we will generate and use will be representative of small random images. It is best to understand this type of operation with a simple example and see how we can use some built-in layers to perform calculations. The first layer we will explore is called a moving window. We will perform a small moving window average across a 2D image and then the second layer will be a custom operation layer.

In this section, we will see that the computational graph can...

Implementing loss functions

Loss functions are very important for machine learning algorithms. They measure the distance between the model outputs and the target (truth) values. In this recipe, we show various loss function implementations in TensorFlow.

Getting ready

In order to optimize our machine learning algorithms, we will need to evaluate the outcomes. Evaluating outcomes in TensorFlow depends on specifying a loss function. A loss function tells TensorFlow how good or bad the predictions are compared to the desired result. In most cases, we will have a set of data and a target on which to train our algorithm. The loss function compares the target to the prediction and gives a numerical distance between the two.

For...

Implementing backpropagation

One of the benefits of using TensorFlow is that it can keep track of operations and automatically update model variables based on back propagation. In this recipe, we will introduce how to use this aspect to our advantage when training machine learning models.

Getting ready

Now, we will introduce how to change our variables in the model in such a way that a loss function is minimized. We have learned how to use objects and operations, and create loss functions that will measure the distance between our predictions and targets. Now, we just have to tell TensorFlow how to back propagate errors through our computational graph to update the variables and minimize the loss function. This is done via...

Working with batch and stochastic training

While TensorFlow updates our model variables according to back propagation, it can operate on anything from one-datum observation to a large batch of data at once. Operating on one training example can make for a very erratic learning process, while using too large a batch can be computationally expensive. Choosing the right type of training is crucial for getting our machine learning algorithms to converge to a solution.

Getting ready

In order for TensorFlow to compute the variable gradients for back propagation to work, we have to measure the loss on a sample or multiple samples. Stochastic training only works on one randomly sampled data-target pair at a time, just as we did in...

Combining everything together

In this section, we will combine everything we have illustrated so far and create a classifier for the iris dataset.

Getting ready

The iris dataset is described in more detail in the Working with data sources recipe in Chapter 1, Getting Started with TensorFlow. We will load this data and make a simple binary classifier to predict whether a flower is the species Iris setosa or not. To be clear, this dataset has three species, but we will only predict whether a flower is a single species, I. setosa or not, giving us a binary classifier. We will start by loading the libraries and data, then transform the target accordingly.

...

Evaluating models

We have already learned how to train a regression and classification algorithm in TensorFlow. After this, we must be able to evaluate the model's predictions to determine how well it did.

Getting ready

Evaluating models is very important and every subsequent model will have some form of model evaluation. Using TensorFlow, we must build this feature into the computational graph and call it while our model is training and/or after it has finished training.

Evaluating models during training gives us an insight into the algorithm and may give us hints to debug it, improve it, or change models entirely. While evaluation during training isn't always necessary, we will show how to do it with both regression...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Exploit the features of Tensorflow to build and deploy machine learning models
  • Train neural networks to tackle real-world problems in Computer Vision and NLP
  • Handy techniques to write production-ready code for your Tensorflow models

Description

TensorFlow is an open source software library for Machine Intelligence. The independent recipes in this book will teach you how to use TensorFlow for complex data computations and allow you to dig deeper and gain more insights into your data than ever before. With the help of this book, you will work with recipes for training models, model evaluation, sentiment analysis, regression analysis, clustering analysis, artificial neural networks, and more. You will explore RNNs, CNNs, GANs, reinforcement learning, and capsule networks, each using Google's machine learning library, TensorFlow. Through real-world examples, you will get hands-on experience with linear regression techniques with TensorFlow. Once you are familiar and comfortable with the TensorFlow ecosystem, you will be shown how to take it to production. By the end of the book, you will be proficient in the field of machine intelligence using TensorFlow. You will also have good insight into deep learning and be capable of implementing machine learning algorithms in real-world scenarios.

Who is this book for?

If you are a data scientist or a machine learning engineer with some knowledge of linear algebra, statistics, and machine learning, this book is for you. If you want to skip the theory and build production-ready machine learning models using Tensorflow without reading pages and pages of material, this book is for you. Some background in Python programming is assumed.

What you will learn

  • Become familiar with the basic features of the TensorFlow library
  • Get to know Linear Regression techniques with TensorFlow
  • Learn SVMs with hands-on recipes
  • Implement neural networks to improve predictive modeling
  • Apply NLP and sentiment analysis to your data
  • Master CNN and RNN through practical recipes
  • Implement the gradient boosted random forest to predict housing prices
  • Take TensorFlow into production

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 31, 2018
Length: 422 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789130768
Category :
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 : Aug 31, 2018
Length: 422 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789130768
Category :
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 $ 132.97
TensorFlow Machine Learning Projects
$38.99
Machine Learning Algorithms
$54.99
TensorFlow Machine Learning Cookbook
$38.99
Total $ 132.97 Stars icon

Table of Contents

12 Chapters
Getting Started with TensorFlow Chevron down icon Chevron up icon
The TensorFlow Way Chevron down icon Chevron up icon
Linear Regression Chevron down icon Chevron up icon
Support Vector Machines Chevron down icon Chevron up icon
Nearest-Neighbor Methods Chevron down icon Chevron up icon
Neural Networks Chevron down icon Chevron up icon
Natural Language Processing Chevron down icon Chevron up icon
Convolutional Neural Networks Chevron down icon Chevron up icon
Recurrent Neural Networks Chevron down icon Chevron up icon
Taking TensorFlow to Production Chevron down icon Chevron up icon
More with TensorFlow Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(3 Ratings)
5 star 0%
4 star 0%
3 star 33.3%
2 star 33.3%
1 star 33.3%
science-dude Feb 29, 2024
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Sadly this book is a bit out of date when Tensorflow 2 was released and Tensorflow 1 made obsolete.
Amazon Verified review Amazon
Stephen P. Owens Jul 31, 2022
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
For starters the book is dated, and the code examples are no longer functional so the first thing I had to do was go in and fix all the code before I could run the examples. The second thing is that this book really doesn't explain or teach anything, you could save the money on the book and go to their Github website download all the example code, fix it till it works and then read the code, you will get just as much out of that as you will by the useless info they add to the code base within the book.
Amazon Verified review Amazon
Amazon Customer Feb 15, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Purchased the latest Edition as I read the first one had lot of errors and typos.When I read around first 50 pages of the book, there were around many typos and more than 8 syntactical errors.Right now I have even stopped counting. The language is very poor. Very poorly written. It miserably fails to explain the concepts. I have read lots of other books on DL but honestly this is the worst book ever. Even if you go to the github repository of this book to refer codes, you will find two versions, one is .ipynb and the other one is .py. Even those files have errors. I don't know how they published the books with out sorting out all these problems.I have finished many DL books within 2-3 weeks because they felt really interesting. Examples: Deep Learning with python, Deep Learning BookBut right now I don't even feel like reading the book because the author has has made simple things way too complicated.Example: we can split data into train n test using sklearn train_test_split. Instead the author is writing 4 lines of code to split them every time. Why man why???I would recommend to go for some other book
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.