Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Deep Learning with TensorFlow
Deep Learning with TensorFlow

Deep Learning with TensorFlow: Explore neural networks with Python

Arrow left icon
Profile Icon Milo Profile Icon Zaccone Profile Icon Menshawy Profile Icon Karim
Arrow right icon
$43.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (10 Ratings)
eBook Apr 2017 320 pages 1st Edition
eBook
$43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Milo Profile Icon Zaccone Profile Icon Menshawy Profile Icon Karim
Arrow right icon
$43.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (10 Ratings)
eBook Apr 2017 320 pages 1st Edition
eBook
$43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$43.99
Paperback
$54.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
Table of content icon View table of contents Preview book icon Preview Book

Deep Learning with TensorFlow

First Look at TensorFlow

TensorFlow is mathematical software and an open-source software library for Machine Intelligence, developed in 2011, by Google Brain Team. The initial target of TensorFlow was to conduct research in machine learning and in deep neural networks. However, the system is general enough to be applicable in a wide variety of other domains as well.

The name is derived from the data model which is represented by tensors and from the data flow graph that stands for the TensorFlow's execution model. In 2015, Google has open-sourced the TensorFlow and all of its reference implementation and made all the source code available on GitHub under the Apache 2.0 license. After that, TensorFlow has achieved wide adaption, form academia and research to industry and following that recently the most stable version 1.0 has been released with a unified API.

Keeping in mind your needs and based on all the latest...

General overview

TensorFlow is an open source software library for numerical computation using data flow graphs that enables machine learning practitioners to do more data-intensive computing. It provides some robust implementations of widely used deep learning algorithms. Nodes in the flow graph represent mathematical operations. On the other hand, the edges represent multidimensional tensors that ensure communication between edges and nodes. TensorFlow offers you a very flexible architecture that enables you to deploy computation to one or more CPUs or GPUs in a desktop, server, or mobile device with a single API.

What's new with TensorFlow 1.x?

The APIs in TensorFlow 1.0 have changed in ways that are not all backward-compatible. That is, TensorFlow programs...

Installing TensorFlow on Linux

In this section, we will show how to install TensorFlow on Ubuntu 14.04 or higher. The instructions presented here also might be applicable for other Linux distros.

Which TensorFlow to install on your platform?

However, before proceeding with the formal steps, we need to determine which TensorFlow to install on your platform. TensorFlow has been developed such that you can run data-intensive tensor application on GPU as well as CPU. Thus, you should choose one of the following types of TensorFlow to install on your platform:

  • TensorFlow with CPU support only: If there is no GPU such as NVIDIA installed on your machine, you must install and start computing using this version. This is very easy and you can do it in just 5 to 10 minutes...

Requirements for running TensorFlow with GPU from NVIDIA

The GPU-enabled version of TensorFlow has several requirements such as 64-bit Linux, Python 2.7 (or 3.3+ for Python 3), NVIDIA CUDA 7.5 (CUDA 8.0 required for Pascal GPUs) and NVIDIA, cuDNN v4.0 (minimum) or v5.1 (recommended). More specifically, the current development of TensorFlow supports only GPU computing using NVIDIA toolkits and software. Now the following software must be installed on your machine.

Step 1: Install NVIDIA CUDA

To use TensorFlow with NVIDIA GPUs, CUDA Toolkit 8.0 and associated NVIDIA drivers with CUDA Toolkit 8+ need to be installed.

For more details, refer to this NVIDIA's documentation
https://developer.nvidia.com/cuda-downloads.

Now download and install the required package from...

How to install TensorFlow

You can install TensorFlow on your machine in a number of ways; such as using virtualenv, pip, Docker, and Anaconda. However, using Docker and Anaconda are a bit advanced and this is why we have decided to use pip and virtualenv instead.

Interested readers can try using Docker and Anaconda from this URL at https://www.tensorflow.org/install/.

Installing TensorFlow with native pip

If Steps 1 to 6 have been completed, install TensorFlow by invoking one of the following commands, for Python 2.7 and of course with only CPU support:

$ pip install tensorflow  

For Python 3.x and of course with only CPU support:

$ pip3 install tensorflow

For Python 2.7 and of course with GPU support:

$ pip install tensorflow-gpu

For Python 3.x and of course...

Installing TensorFlow on Windows

If you can't get a Linux-based system, you must install Ubuntu on a virtual machine; just use a free application called VirtualBox, which lets you create a virtual PC on Windows and install Ubuntu in it. TensorFlow only supports version 3.5.x of Python on Windows. Note that Python 3.5.x comes with the pip3 package manager, which is the program you'll use to install TensorFlow. To install TensorFlow, start a command prompt and then issue the appropriate pip3 install command in that terminal. To install the CPU-only version of TensorFlow, enter the following command:

C:> pip3 install --upgrade tensorflow 

To install the GPU version of TensorFlow, enter the following command:

C:> pip3 install --upgrade tensorflow-gpu 

Installation from source

...

Computational graphs

When performing an operation, for example training a neural network, or the sum of two integers, TensorFlow internally represent, its computation using a data flow graph (or computational graph).

This is a directed graph consisting of the following:

  • A set of nodes, each one representing an operation
  • A set of directed arcs, each one representing the data on which the operations are performed

TensorFlow has two types of edge:

  • Normal: They are only carriers of data structures, between the nodes. The output of one operation (from one node) becomes the input for another operation. The edge connecting two nodes carry the values.
  • Special: This edge doesn't carry values. It represents a control dependency between two nodes A and B. It means that the node B will be executed only if the operation in A will be ended before the relationship between operations on the data.

The TensorFlow implementation...

Why a computational graph?

Another key idea in TensorFlow is the deferred execution, during the building phase of the computational graph, you can compose very complex expressions (we say it is highly compositional), when you want to evaluate them through the running session phase, TensorFlow schedules the running in the most efficient manner (for example, parallel execution of independent parts of the code using the GPU).

In this way, a graph helps to distribute the computational load if one must deal with complex models containing a large number of nodes and layers.

Finally, a neural network can be compared to a composite function where each network layer can be represented as a function.

This consideration leads us to the next section, where the role of the computational graph in implementing a neural network is explained.

...

The programming model

A TensorFlow program is generally divided into three phases:

  • Construction of the computational graph
  • Running a session, which is performed for the operations defined in the graph
  • Resulting data collection and analysis

These main steps define the programming model in TensorFlow.

Consider the following example, in which we want to multiply two numbers.

import tensorflow as tf 
with tf.Session() as session:
x = tf.placeholder(tf.float32,[1],name="x")
y = tf.placeholder(tf.float32,[1],name="y")
z = tf.constant(2.0)
y = x * z
x_in = [100]
y_output = session.run(y,{x:x_in})
print(y_output)

Surely TensorFlow is not necessary to multiply two numbers; also the number of lines of the code for this simple operation is so many. However, the example wants to clarify how to structure any code, from the simplest as in this instance, to the most complex.

Furthermore, the...

Data model

The data model in TensorFlow is represented by tensors. Without using complex mathematical definitions, we can say that a tensor (in TensorFlow) identifies a multidimensional numerical array.

This data structure is characterized by three parameters--Rank, Shape, and Type.

Rank

Each tensor is described by a unit of dimensionality called rank. It identifies the number of dimensions of the tensor, for this reason, a rank is a known-as order or n-dimensions of a tensor. A rank zero tensor is a scalar, a rank one tensor ID a vector, while a rank two tensor is a matrix.

The following code defines a TensorFlow scalar, a vector, a matrix and a cube_matrix, in the next example we show how the rank works:

 
import tensorflow as tf

scalar = tf.constant(100)
vector...

TensorBoard

When training a neural network, it may be useful to keep track of network parameters, typically the inputs and outputs from the nodes, so you can see whether your model is learning such verifying after each training step if the function error is minimized or not. Of course, writing code to display the behavior of the network during the learning phase, it can be not easy.

Installing TensorBoard is pretty straight forward. Just issue the following command on Terminal (On Ubuntu for Python 2.7+):
$ sudo pip install tensorboard

Fortunately, TensorFlow provides TensorBoard which is a framework designed for analysis and debugging of neural network models. TensorBoard uses the so-called summaries to view the parameters of the model; once a TensorFlow code is executed, we can call TensorBoard to view summaries in a graphical user interface (GUI).

Furthermore, TensorBoard can be used to display and study the...

Implementing a single input neuron

In this example, we will take a closer look at TensorFlow's and TensorBoard's main concepts and try to do some basic operations to get you started. The model we want to implement simulates a single neuron. For reference, see the following diagram:

A schema representing the single input neuron

The output will be the input product for the weight.

The preceding schema consists of the following:

  • An input value, which stimulates the neuron.
  • A single weight, which is multiplied by the input, provides the output of the neuron. The weight value will vary in the course of the training procedure.
  • The output is given by the product input x weight. The neuron will learn when the given output will be issued next to the expected value.
  • These elements are enough to define the model. The input value represents a stimulus to the neuron. It is a constant which is defined with the TensorFlow...

Source code for the single input neuron

We reported for the entire source code for the example previously described is as follows:

import tensorflow as tf 

input_value = tf.constant(0.5,name="input_value")
weight = tf.Variable(1.0,name="weight")
expected_output = tf.constant(0.0,name="expected_output")
model = tf.multiply(input_value,weight,"model")loss_function = tf.pow(expected_output - model,2,name="loss_function")
optimizer = tf.train.GradientDescentOptimizer(0.025).minimize(loss_function)

for value in [input_value,weight,expected_output,model,loss_function]:
tf.summary.scalar(value.op.name,value)
summaries = tf.summary.merge_all()sess = tf.Session()
summary_writer = tf.summary.FileWriter('log_simple_stats',sess.graph)
sess.run(tf.global_variables_initializer())
for i in range(100):
summary_writer.add_summary(sess.run(summaries),i)
sess.run...

Migrating to TensorFlow 1.x

The latest release of TensorFlow 1.0 has left in ways such that all the computing and using reusing the previous codes that all of them are not backward compatible. This means an application developed on TensorFlow 0.x won't necessarily work on TensorFlow 1.x directly. Now to upgrade 0.x codes to 1.x compatible, there are two ways using the upgrade script or manually.

How to upgrade using the script

Summary

TensorFlow is designed to make distributed machine and deep learning easy for everyone, but using it does require understanding some general principles and algorithms. Furthermore, the latest release of TensorFlow comes with lots of exciting features. Thus we also tried to cover them so that you can use them with ease. We have shown how to install TensorFlow on different platforms including Linux, Windows, and Mac OS. Before, covering this in even greater depth, we showed some example of how to upgrade the source code from the previous version of TensorFlow to the latest version 1.x.

In summary, here is a brief recap of the key concepts of TensorFlow explained in this chapter:

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn how to implement advanced techniques in deep learning with Google’s brainchild, TensorFlow
  • Explore deep neural networks and layers of data abstraction with the help of this comprehensive guide
  • Real-world contextualization through some deep learning problems concerning research and application

Description

Deep learning is the step that comes after machine learning, and has more advanced implementations. Machine learning is not just for academics anymore, but is becoming a mainstream practice through wide adoption, and deep learning has taken the front seat. As a data scientist, if you want to explore data abstraction layers, this book will be your guide. This book shows how this can be exploited in the real world with complex raw data using TensorFlow 1.x. Throughout the book, you’ll learn how to implement deep learning algorithms for machine learning systems and integrate them into your product offerings, including search, image recognition, and language processing. Additionally, you’ll learn how to analyze and improve the performance of deep learning models. This can be done by comparing algorithms against benchmarks, along with machine intelligence, to learn from the information and determine ideal behaviors within a specific context. After finishing the book, you will be familiar with machine learning techniques, in particular the use of TensorFlow for deep learning, and will be ready to apply your knowledge to research or commercial projects.

Who is this book for?

The book is intended for a general audience of people interested in machine learning and machine intelligence. A rudimentary level of programming in one language is assumed, as is a basic familiarity with computer science techniques and technologies, including a basic awareness of computer hardware and algorithms. Some competence in mathematics is needed to the level of elementary linear algebra and calculus.

What you will learn

  • Learn about machine learning landscapes along with the historical development and progress of deep learning
  • Learn about deep machine intelligence and GPU computing with the latest TensorFlow 1.x
  • Access public datasets and utilize them using TensorFlow to load, process, and transform data
  • Use TensorFlow on real-world datasets, including images, text, and more
  • Learn how to evaluate the performance of your deep learning models
  • Using deep learning for scalable object detection and mobile computing
  • Train machines quickly to learn from data by exploring reinforcement
  • learning techniques
  • Explore active areas of deep learning research and applications

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 24, 2017
Length: 320 pages
Edition : 1st
Language : English
ISBN-13 : 9781786460127
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

Product Details

Publication date : Apr 24, 2017
Length: 320 pages
Edition : 1st
Language : English
ISBN-13 : 9781786460127
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 $ 170.97
Deep Learning with Keras
$54.99
Deep Learning with TensorFlow
$54.99
TensorFlow Machine Learning Cookbook
$60.99
Total $ 170.97 Stars icon

Table of Contents

10 Chapters
Getting Started with Deep Learning Chevron down icon Chevron up icon
First Look at TensorFlow Chevron down icon Chevron up icon
Using TensorFlow on a Feed-Forward Neural Network Chevron down icon Chevron up icon
TensorFlow on a Convolutional Neural Network Chevron down icon Chevron up icon
Optimizing TensorFlow Autoencoders Chevron down icon Chevron up icon
Recurrent Neural Networks Chevron down icon Chevron up icon
GPU Computing Chevron down icon Chevron up icon
Advanced TensorFlow Programming Chevron down icon Chevron up icon
Advanced Multimedia Programming with TensorFlow Chevron down icon Chevron up icon
Reinforcement Learning Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(10 Ratings)
5 star 10%
4 star 10%
3 star 10%
2 star 10%
1 star 60%
Filter icon Filter
Top Reviews

Filter reviews by




Verified Amazon Customer Jul 22, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book. It contains lots of practical examples. However, when I copied the codes from the book, there were some alignment issues and some codes were not executed correctly. Therefore, I had to manually fixed them.Fortunately, the authors have fixed all the minor bugs and the updated codes that I have downloaded from GitHub/Deep-Learning-with-TensorFlow are working perfectly.
Amazon Verified review Amazon
Ambuj Jan 07, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good introduction if you want to start with tensor flow
Amazon Verified review Amazon
Matthew R. Versaggi Jan 03, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I had such high hopes for this book - the theory is OK, but this is supposed to be a practitioners book with code that actually works and is of Tensorflor 1.X whereas there is lots of code pre-tensorflow 1.x in the code base which generate difficult errors to debug.I'm in Ch 3 and scrapping the book for something else. Sad.Update:I have seen improvements in Ch4 with CNN's the code is cleaner and the explanation is improving.
Amazon Verified review Amazon
Barry Hart Jun 30, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Much of the book seems like a rehash or even direct quotes from the TensorFlow Dev Summit put on by Google in early 2017. If you've watched the videos, this book might serve as a good set of notes. The book doesn't have much flow or unity. If you're looking to learn TensorFlow from scratch, I recommend Hands-On Machine Learning with Scikit-Learn and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems instead.
Amazon Verified review Amazon
Dimitri Shvorob Mar 12, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Wishing to learn about TensorFlow, I decided to survey TF books available from Amazon, and pick one or two for further study. I excluded self-published offerings, and ended up with this longish list, dominated by Packt titles:"Machine Learning with TensorFlow" by Shukla, published by Manning in 2018-02, 272 pp, $43"Mastering TensorFlow 1.x" by Fandango, Packt, 2018-01, 474 pp, $35"Pro Deep Learning with TensorFlow" by Pattanayak, Apress, 2017-12, 398 pp, $37"TensorFlow 1.x Deep Learning Cookbook" by Gulli and Kapoor, Packt, 2017-12, 536 pp, $32"Neural Network Programming with TensorFlow" by Ghotra and Dua, Packt, 2017-11, 274 pp, $40"Predictive Analytics with TensorFlow" by Karim, Packt, 2017-11, 522 pp, $50"Machine Learning with TensorFlow 1.x" by Hua and Azeem, Packt, 2017-11, 304 pp, $39"Learning TensorFlow" by Hope and Resheff, O'Reilly, 2017-08, 242 pp, $25"Hands-On Deep Learning with TensorFlow" by Van Boxel, Packt, 2017-07, 174 pp, $35"Deep Learning with TensorFlow" by Zaccone, Karim, Menshawy, Packt, 2017-04, 320 pp, $50"TensorFlow Machine Learning Cookbook" by McClure, Packt, 2017-02, 370 pp, $30"Building Machine Learning Projects with TensorFlow" by Bonnin, Packt, 2016-11, 291 pp, $35"Getting Started with TensorFlow" by Zaccone, Packt, 2016-07, 180 pp, $35I reviewed the doc on tensorflow.org - including the doc for older releases - then started looking at books. One week later, I am still not done, but have winnowed out some options. The books by Van Boxel and Zaccone are out - these are brief (and not up-to-date) introductions, costing as much as more substantial titles - and the book by Karim is "disqualified" for blatant plagiarism.What happens when Messrs Zaccone and Karim collaborate? It seems that the former continues to do honest work, and the latter continues to pilfer content. I am reading an electronic copy and cannot point to page numbers, but a chunk of "Neural networks as computational graphs" Section in Chapter 1 seems to be purloined from Brandon Brown of Outlace.com (see post "On chain rule, computational graphs, and back-propagation"), and Chapter 10, "Reinforcement learning", is taken without attribution from Arthur Juliani. Sorry, I have to stop here, give one star and move on. It's a pity, because "Deep Learning with TensorFlow" has substance - as copy-pastes go, this is a fairly wide-ranging, and undeniably enriched, copy-paste - but plagiarism should not be encouraged.
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.