Reader small image

You're reading from  Mobile Artificial Intelligence Projects

Product typeBook
Published inMar 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789344073
Edition1st Edition
Languages
Right arrow
Authors (3):
Karthikeyan NG
Karthikeyan NG
author image
Karthikeyan NG

Karthikeyan NG is the Head of Engineering and Technology at the Indian lifestyle and fashion retail brand. He served as a software engineer at Symantec Corporation and has worked with 2 US-based startups as an early employee and has built various products. He has 9+ years of experience in various scalable products using Web, Mobile, ML, AR, and VR technologies. He is an aspiring entrepreneur and technology evangelist. His interests lie in exploring new technologies and innovative ideas to resolve a problem. He has also bagged prizes from more than 15 hackathons, is a TEDx speaker and a speaker at technology conferences and meetups as well as guest lecturer at a Bengaluru University. When not at work, he is found trekking.
Read more about Karthikeyan NG

Arun Padmanabhan
Arun Padmanabhan
author image
Arun Padmanabhan

Arun Padmanabhan is a Machine Learning consultant with over 8 years of experience building end-to-end machine learning solutions and applications. Currently working with a couple of start-ups in the Financial and Insurance industries, he specializes in automating manual workflows using AI and creating Machine Vision and NLP applications. In past, he has led the data science team of a Singapore based product startup in the restaurant domain. He also has built stand-alone and integrated Machine Learning solutions in the Manufacturing, Shipping and e-commerce domains over the years. His interests are in research, development and applications of Artificial Intelligence and Deep Architectures.
Read more about Arun Padmanabhan

Matt Cole
Matt Cole
author image
Matt Cole

Matt R. Cole is a developer and author with 30 years' experience. Matt is the owner of Evolved AI Solutions, a provider of advanced Machine Learning/Bio-AI, Microservice and Swarm technologies. Matt is recognized as a leader in Microservice and Artificial Intelligence development and design. As an early pioneer of VOIP, Matt developed the VOIP system for NASA for the International Space Station and Space Shuttle. Matt also developed the first Bio Artificial Intelligence framework which completely integrates mirror and canonical neurons. In his spare time Matt authors books, and continues his education taking every available course in advanced mathematics, AI/ML/DL, Quantum Mechanics/Physics, String Theory and Computational Neuroscience.
Read more about Matt Cole

View More author details
Right arrow

Implementing Deep Net Architectures to Recognize Handwritten Digits

In the previous chapters, we have been through the essential concepts and have set up tools that are required for us to get our journey into Artificial Intelligence (AI) started. We also built a small prediction app to get our feet wet with the tools we will be using.

In this chapter, we are going to cover a more interesting and popular application of AI – Computer Vision, or Machine Vision. We will start by continuing from the previous chapter and ease into building convolutional neural networks (CNN), the most popular neural network type for Computer Vision. This chapter will also cover the essential concepts that were promised in Chapter 1, Artificial Intelligence Concepts and Fundamentals, but, in contrast, this chapter will have a very hands-on approach.

We will be covering the following topics in...

Building a feedforward neural network to recognize handwritten digits, version one

In this section, we will use the knowledge that we gained from the last two chapters to tackle a problem that has unstructured data – image classification. The idea is to take a dive into solving a Computer Vision task with the current setup and the basics of neural networks that we are familiar with. We have seen that feedforward neural networks can be used for prediction using structured data; let's try that on images to classify handwritten digits.

To solve this task, we are going to leverage the MNSIT database and use the handwritten digits dataset. MNSIT stands for Modified National Institute of Standards and Technology. It is a large database that's commonly used for training, testing, and benchmarking image-related tasks in Computer Vision.

The MNSIT digits dataset contains...

Building a feedforward neural network to recognize handwritten digits, version two

In the previous section, we built a very simple neural network with just an input and output layer. This simple neural network gave us an accuracy of 86%. Let's see if we can improve this accuracy further by building a neural network that is a little deeper than the previous version:

  1. Let's do this on a new notebook. Loading the dataset and data pre-processing will be the same as in the previous section:
import numpy as np
np.random.seed(42)
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SG
#loading and pre-processing data
(X_train,y_train), (X_test,y_test)= mnist.load_data() X_train= X_train.reshape( 60000, 784). astype('float32')
X_test =X_test.reshape(10000,784).astype('float32&apos...

Building a deeper neural network

In this section, we will use the concepts we learned about in this chapter to build a deeper neural network to classify handwritten digits:

  1. We will start with a new notebook and then load the required dependencies:
import numpy as np
np.random.seed(42) import keras from keras.datasets import mnist from keras.models import Sequential
from keras.layers import Dense from keras.layers import Dropout # new! from keras.layers.normalization
# new! import BatchNormalization # new! from keras import regularizers # new! from keras.optimizers import SGD
  1. We will now load and pre-process the data:
(X_train,y_train),(X_test,y_test)= mnist.load_data()
X_train= X_train.reshape(60000,784).
astype('float32')
X_test= X_test.reshape(10000,784).astype('float32')
X_train/=255 X_test/=255 n_classes=10 y_train=keras.utils.to_categorical(y_train,n_classes...

Introduction to Computer Vision

Computer Vision can be defined as the subset of AI where we can teach a computer to see. We cannot just add a camera to a machine in order for it to see. For a machine to actually view the world like people or animals do, it relies on Computer Vision and image recognition techniques. Reading barcodes and face recognition are examples of Computer Vision. Computer Vision can be described as that part of the human brain that processes the information that's perceived by the eyes, nothing else.

Image recognition is one of the interesting uses of Computer Vision from an AI standpoint. The input that is received through Computer Vision on the machine is interpreted by the image recognition system, and based on what it sees, the output is classified.

In other words, we use our eyes to capture the objects around us, and those objects/images are processed...

Summary

In this chapter, we built a feedforward neural network to recognize handwritten digits in two versions. Then, we built a neural network to classify handwritten digits, and, finally we gave a short introduction to Computer Vision.

In the next chapter, we will build a Machine Vision mobile app to classify flower species and retrieve the necessary information.

Further reading

For in-depth knowledge on computer vision, do refer the following Packt books:

  • Deep Learning for Computer Vision by Rajalingappaa Shanmugamani
  • Practical Computer Vision by Abhinav Dadhich
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mobile Artificial Intelligence Projects
Published in: Mar 2019Publisher: PacktISBN-13: 9781789344073
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.
undefined
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 $15.99/month. Cancel anytime

Authors (3)

author image
Karthikeyan NG

Karthikeyan NG is the Head of Engineering and Technology at the Indian lifestyle and fashion retail brand. He served as a software engineer at Symantec Corporation and has worked with 2 US-based startups as an early employee and has built various products. He has 9+ years of experience in various scalable products using Web, Mobile, ML, AR, and VR technologies. He is an aspiring entrepreneur and technology evangelist. His interests lie in exploring new technologies and innovative ideas to resolve a problem. He has also bagged prizes from more than 15 hackathons, is a TEDx speaker and a speaker at technology conferences and meetups as well as guest lecturer at a Bengaluru University. When not at work, he is found trekking.
Read more about Karthikeyan NG

author image
Arun Padmanabhan

Arun Padmanabhan is a Machine Learning consultant with over 8 years of experience building end-to-end machine learning solutions and applications. Currently working with a couple of start-ups in the Financial and Insurance industries, he specializes in automating manual workflows using AI and creating Machine Vision and NLP applications. In past, he has led the data science team of a Singapore based product startup in the restaurant domain. He also has built stand-alone and integrated Machine Learning solutions in the Manufacturing, Shipping and e-commerce domains over the years. His interests are in research, development and applications of Artificial Intelligence and Deep Architectures.
Read more about Arun Padmanabhan

author image
Matt Cole

Matt R. Cole is a developer and author with 30 years' experience. Matt is the owner of Evolved AI Solutions, a provider of advanced Machine Learning/Bio-AI, Microservice and Swarm technologies. Matt is recognized as a leader in Microservice and Artificial Intelligence development and design. As an early pioneer of VOIP, Matt developed the VOIP system for NASA for the International Space Station and Space Shuttle. Matt also developed the first Bio Artificial Intelligence framework which completely integrates mirror and canonical neurons. In his spare time Matt authors books, and continues his education taking every available course in advanced mathematics, AI/ML/DL, Quantum Mechanics/Physics, String Theory and Computational Neuroscience.
Read more about Matt Cole