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

Classifying digits using TensorFlow Lite


To complete this project, we will use the MNIST digit dataset, which is available in the TensorFlow datasets library (https://www.tensorflow.org/guide/datasets). It consists of images of handwritten digits from 0 to 9. The training dataset has 60,000 images and the testing set has 10,000 images. Some of the images in the dataset are as follows:

If we take a look at TensorFlowLite tutorials, we will see that the focus is on using pre-trained models such as Mobilenet or retraining the existing ones. However, none of these tutorials talk about building new models, which is something we will be doing here. 

Note

Note that we specifically choose a simple model because at the time of writing this book, TensorFlow Lite doesn't have adequate support for all types of complex models

We will use categorical cross entropy as the loss function for this classification problem. Categorical cross entropy was explained in detail in Chapter 3Sentiment Analysis in Your...