Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Machine Learning Projects for Mobile Applications

You're reading from  Machine Learning Projects for Mobile Applications

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781788994590
Pages 246 pages
Edition 1st Edition
Languages
Author (1):
Karthikeyan NG Karthikeyan NG
Profile icon Karthikeyan NG
Toc

Building the TensorFlow model


In this application, we will build an MNIST dataset-based TensorFlow model to be used in our Android application. Once we have the TensorFlow model, we will convert that into a TensorFlow Lite model. The step-by-step procedure on downloading the model and building the TensorFlow model is as follows.

Here is the architecture diagram on how our model works. The way to achieve the same is explained further:

With TensorFlow, we can download the data with one line of Python code, as follows:

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# Reading data
mnist = input_data.read_data_sets("./data/", one_hot=True)

Now we have the MNIST dataset downloaded. After that, we will read the data as shown precedingly. Now we can run the script to download the dataset. We will run the script from the console as follows:

 > python mnist.py
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting MNIST_data/train-images-idx3...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime