Book Image

TensorFlow Machine Learning Projects

By : Ankit Jain, Amita Kapoor
Book Image

TensorFlow Machine Learning Projects

By: Ankit Jain, Amita Kapoor

Overview of this book

TensorFlow has transformed the way machine learning is perceived. TensorFlow Machine Learning Projects teaches you how to exploit the benefits—simplicity, efficiency, and flexibility—of using TensorFlow in various real-world projects. With the help of this book, you’ll not only learn how to build advanced projects using different datasets but also be able to tackle common challenges using a range of libraries from the TensorFlow ecosystem. To start with, you’ll get to grips with using TensorFlow for machine learning projects; you’ll explore a wide range of projects using TensorForest and TensorBoard for detecting exoplanets, TensorFlow.js for sentiment analysis, and TensorFlow Lite for digit classification. As you make your way through the book, you’ll build projects in various real-world domains, incorporating natural language processing (NLP), the Gaussian process, autoencoders, recommender systems, and Bayesian neural networks, along with trending areas such as Generative Adversarial Networks (GANs), capsule networks, and reinforcement learning. You’ll learn how to use the TensorFlow on Spark API and GPU-accelerated computing with TensorFlow to detect objects, followed by how to train and develop a recurrent neural network (RNN) model to generate book scripts. By the end of this book, you’ll have gained the required expertise to build full-fledged machine learning projects at work.
Table of Contents (23 chapters)
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Index

Preface

TensorFlow has transformed the way machine learning is perceived. TensorFlow Machine Learning Projects teaches you how to exploit the benefits—simplicity, efficiency, and flexibility—of using TensorFlow in various real-world projects. With the help of this book, you'll not only learn how to build advanced projects using different datasets, but also be able to tackle common challenges using a range of libraries from the TensorFlow ecosystem.

To begin with, you'll get to grips with using TensorFlow for machine learning projects. You'll explore a wide range of projects using TensorForest and TensorBoard for detecting exoplanets, TensorFlow.js for sentiment analysis, and TensorFlow Lite for digit classification.

As you make your way through the book, you'll build projects in various real-world domains incorporating natural language processing (NLP), the Gaussian process, autoencoders, recommender systems, and Bayesian neural networks, along with trending areas such as generative adversarial networks (GANs), capsule networks, and reinforcement learning. You'll learn to use TensorFlow with the Spark API and explore GPU-accelerated computing with TensorFlow in order to detect objects, followed by understanding how to train and develop a recurrent neural network (RNN) model to generate book scripts.

By the end of this book, you'll have gained the required expertise to build full-fledged machine learning projects at work.

Who this book is for

TensorFlow Machine Learning Projects is for you if you are a data analyst, data scientist, machine learning professional, or deep learning enthusiast with a basic knowledge of TensorFlow. This book is also for you if you want to build end-to-end projects in the machine learning domain using supervised, unsupervised, and reinforcement learning techniques.

What this book covers

Chapter 1, Overview of TensorFlow and Machine Learning, explains the basics of TensorFlow and has you build a machine learning model using logistic regression to classify hand-written digits.

Chapter 2, Using Machine Learning to Detect Exoplanets in Outer Space, covers how to detect exoplanets in outer space using ensemble methods that are based on decision trees.

Chapter 3, Sentiment Analysis in Your Browser Using TensorFlow.js, explains how to train and build a model on your web browser using TensorFlow.js. We will build a sentiment analysis model using a movie reviews dataset and deploy it to your web browser for making predictions.

Chapter 4, Digit Classification Using TensorFlow Lite, focuses on building a deep learning model for classifying hand-written digits and converting them into a mobile-friendly format using TensorFlow Lite. We will also learn about the architecture of TensorFlow Lite and how to use TensorBoard for visualizing neural networks.

Chapter 5, Speech to Text and Topic Extraction Using NLP, focuses on learning about various options for speech-to-text and pre-built models by Google in TensorFlow using the Google Speech Command dataset.

Chapter 6, Predicting Stock Prices using Gaussian Process Regression, explains a popular forecasting model called a Gaussian process in Bayesian statistics. We use Gaussian processes from a GpFlow library built on top of TensorFlow to develop a stock price prediction model. 

Chapter 7, Credit Card Fraud Detection Using Autoencoders, introduces a dimensionality reduction technique called autoencoders. We identify fraudulent transactions in a credit card dataset by building autoencoders using TensorFlow and Keras.

Chapter 8, Generating Uncertainty in Traffic Signs Classifier using Bayesian Neural Networks, explains Bayesian neural networks, which help us to quantify the uncertainty in predictions. We will build a Bayesian neural network using TensorFlow to classify German traffic signs. 

Chapter 9Generating Matching Shoe Bags from Shoe Images Using DiscoGANs, introduces a new type of GAN known as Discovery GANs (DiscoGANs). We understand how its architecture differs from standard GANs and how it can be used in style transfer problems. Finally, we build a DiscoGAN model in TensorFlow to generate matching shoe bags from shoe images, and vice versa.

Chapter 10, Classifying Clothing Images Using Capsule Networks, implements a very recent image classification model—Capsule Networks. We get to understand its architecture and explain the nuances of its implementation in TensorFlow. We use the Fashion MNIST dataset to classify clothing images using this model.

Chapter 11, Making Quality Product Recommendations Using TensorFlow, covers techniques such as matrix factorization (SVD++), learning to rank, and convolutional neural network variations for recommendation tasks with TensorFlow.

Chapter 12, Object Detection at a Large Scale with TensorFlow, explores Yahoo's TensorFlowOnSpark framework for distributed deep learning on Spark clusters. Then, we will apply TensorFlowOnSpark to a large-scale dataset of images and train the network to detect objects. 

Chapter 13, Generating Book Scripts Using LSTMs, explains how LSTMs are useful in generating new text. We use a book script from one of Packt's published books to bsuild an LSTM-based deep learning model that can generate book scripts on its own. 

Chapter 14, Playing Pacman Using Deep Reinforcement Learning, explains the utilization of reinforcement learning for training a model to play Pacman, teaching you about reinforcement learning in the process.

Chapter 15What is Next?, introduces the other components of the TensorFlow ecosystem that are useful for deploying the models in production. We will also learn about various applications of AI across industries, the limitations of deep learning, and ethics in AI.

To get the most out of this book

To get the most out of this book, download the book code from the GitHub repository and practice with the code in Jupyter Notebooks. Also, practice modifying the implementations already provided by the authors. 

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/TensorFlow-Machine-Learning-Projects. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789132212_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "By defining placeholders and passing the values to session.run()."

A block of code is set as follows:

tf.constant(
  value,
  dtype=None,
  shape=None,
  name='const_name',
  verify_shape=False
  )

Any command-line input or output is written as follows:

const1 (x):  Tensor("x:0", shape=(), dtype=int32)
const2 (y):  Tensor("y:0", shape=(), dtype=float32)
const3 (z):  Tensor("z:0", shape=(), dtype=float16)

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Type a review into the box provided and click Submit to see the model's predicted score."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.