36,59 €
Use the power of deep learning with Python to build and deploy intelligent web applications
Key Features
Book Description
When used effectively, deep learning techniques can help you develop intelligent web apps. In this book, you'll cover the latest tools and technological practices that are being used to implement deep learning in web development using Python.
Starting with the fundamentals of machine learning, you'll focus on DL and the basics of neural networks, including common variants such as convolutional neural networks (CNNs). You'll learn how to integrate them into websites with the frontends of different standard web tech stacks. The book then helps you gain practical experience of developing a deep learning-enabled web app using Python libraries such as Django and Flask by creating RESTful APIs for custom models. Later, you'll explore how to set up a cloud environment for deep learning-based web deployments on Google Cloud and Amazon Web Services (AWS). Next, you'll learn how to use Microsoft's intelligent Emotion API, which can detect a person's emotions through a picture of their face. You'll also get to grips with deploying real-world websites, in addition to learning how to secure websites using reCAPTCHA and Cloudflare. Finally, you'll use NLP to integrate a voice UX through Dialogflow on your web pages.
By the end of this book, you'll have learned how to deploy intelligent web apps and websites with the help of effective tools and practices.
What you will learn
Who this book is for
This deep learning book is for data scientists, machine learning practitioners, and deep learning engineers who are looking to perform deep learning techniques and methodologies on the web. You will also find this book useful if you're a web developer who wants to implement smart techniques in the browser to make it more interactive. Working knowledge of the Python programming language and basic machine learning techniques will be beneficial.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 420
Veröffentlichungsjahr: 2020
Copyright © 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Sunith ShettyAcquisition Editor: Ali AbidiContent Development Editor: Pratik AndradeSenior Editor: Ayaan HodaTechnical Editor: Sarvesh JaywantCopy Editor: Safis EditingProject Coordinator: Neil DmelloProofreader: Safis EditingIndexer: Manju ArasanProduction Designer: Alishon Mendonsa
First published: May 2020
Production reference: 1150520
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78995-608-5
www.packt.com
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Anubhav Singh, a web developer since before Bootstrap was launched, is an explorer of technologies, often pulling off crazy combinations of uncommon tech. An international rank holder in the Cyber Olympiad, he started off by developing his own social network and search engine as his first projects at the age of 15, which stood among the top 500 websites of India during their operational years. He's continuously developing software for the community in domains with roads less walked on. You can often catch him guiding students on how to approach ML or the web, or both together. He's also the founder of The Code Foundation, an AI-focused start-up. Anubhav is a Venkat Panchapakesan Memorial Scholarship awardee and an Intel Software Innovator.
Sayak Paul is currently with PyImageSearch, where he applies deep learning to solve real-world problems in computer vision and bring solutions to edge devices. He is responsible for providing Q&A support to PyImageSearch readers. His areas of interest include computer vision, generative modeling, and more. Previously at DataCamp, Sayak developed projects and practice pools. Prior to DataCamp, Sayak worked at TCS Research and Innovation (TRDDC) on data privacy. There, he was a part of TCS's critically acclaimed GDPR solution called Crystal Ball. Outside of work, Sayak loves to write technical articles and speak at developer meetups and conferences.
Karan Bhanot is a computer science graduate from Punjab Engineering College, India. He is a machine learning and data science enthusiast. He has worked on numerous projects involving Python, Jupiter Notebook, NumPy, pandas, Matplotlib, Flask, Flask-RESTPlus, neural networks (Keras and TensorFlow), R, Shiny, Leaflet, and ggplot. As a frontend developer, he has also worked on HTML, CSS, and JavaScript. He is currently pursuing a PhD in computer science with a research focus on data science and machine learning. He is active on GitHub and blogs his ideas and learnings on online blogging websites such as Medium.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Deep learning techniques can be used to develop intelligent web apps. Over the last few years, tremendous growth in the number of companies adopting deep learning techniques in their products and businesses has been observed. There has been a significant surge in the number of start-ups providing AI and deep learning-based solutions for niche problems. This book introduces numerous tools and technological practices used to implement deep learning in web development using Python.
To start with, you will learn about the fundamentals of machine learning, with a focus on deep learning and the basics of neural networks, along with their common variants, such as convolutional neural networks, and how you can integrate them into websites with frontends built with different standard web tech stacks. You will create your deep learning-enabled web application using Python libraries such as Django and Flask by creating REST APIs for custom models. You will set up a cloud environment for deep learning-based web deployments on Google Cloud and AWS, and get guidance on how to use their battle-tested deep learning APIs. Further, you will use Microsoft's Intelligent Emotion API, which can detect human emotions from a picture of a face. You will also get to grips with deploying real-world websites, and you will get great insights into securing those websites using reCaptcha and Cloudflare for a robust experience. Finally, you will use natural language processing to recommend restaurants from user reviews and to integrate a voice UX on your web pages through Dialogflow.
By the end of this book, you'll be able to deploy your intelligent web apps and websites with the help of the best tools and practices.
This book is for data scientists, machine learning practitioners, and deep learning engineers who are looking to perform deep learning techniques and methodologies on the web. This book will also be ideal for web developers who want to use smart techniques in the browser to make it more interactive. You will gain deep insights into browser data using this handy guide.
Having a working knowledge of the Python programming language and fundamental machine learning techniques (as covered in the Machine Learning Crash Course by Google, available at https://developers.google.com/machine-learning/crash-course) will be beneficial for reading this book.
Chapter 1, Demystifying Artificial Intelligence and Fundamentals of Machine Learning, briefly introduces machine learning, deep learning, and other forms of artificial intelligence methodologies related to web development. This chapter quickly goes over fundamental topics of the machine learning pipeline, such as exploratory data analysis, data preprocessing, feature engineering, training and testing, models of evaluation, and more. Toward the end, a comparison between the interactivity and user experience offered by websites before AI became popular and how they are in the modern day is presented. We also study the usage of AI on the web by some of the biggest firms and how AI has revolutionized their products.
Chapter 2, Getting Started with Deep Learning Using Python, introduces basic concepts and terminologies related to deep learning and how to use deep learning to build a simple web app with different deep learning libraries in Python.
Chapter 3, Creating Your First Deep Learning Web Application, discusses several important concepts regarding the structure of web applications specifically for leveraging deep learning. It then proceeds to discuss the approaches to understanding a dataset. The chapter also shows how to implement and improve a simple neural network and how it can be wrapped into an API for the development of a simple web application. We then proceed to showcase how the API can be implemented using different standard web tech stacks.
Chapter 4, Getting Started with TensorFlow.js, introduces the most popular JavaScript library for deep learning—TensorFlow.js (Tf.js). It gives a brief overview of what TensorFlow.js is and the things it is capable of doing in a browser. Furthermore, this chapter shows how you can use pre-trained models using TensorFlow.js and build a simple web application with it.
Chapter 5, Deep Learning through APIs, introduces the concept of APIs and their importance in software development. Further, the chapter proceeds to show examples of different deep learning APIs. Toward the very end, the chapter presents an approach to choosing deep learning API providers to suit particular use cases. The deep learning APIs covered are the Vision API, the Text API, and others.
Chapter 6, Deep Learning on Google Cloud Platform Using Python, introduces the offerings by Google Cloud Platform for web developers to integrate into their websites. The focus is on Dialogflow, which can be used to make chatbots and conversational AIs; the Cloud Inference API, which can be used to build a good recommendation system; and also the Translation API, which is used to provide users in different locales with website content in their languages. The chapter discusses their applications at length and also demonstrates a basic how-to for using them with Python.
Chapter 7, DL on AWS Using Python: Object Detection and Home Automation, introduces Amazon Web Services and talks briefly about the various offerings, including the Alexa API and the Rekognition API. The Alexa API can be used to build home automation web apps and other interactive interfaces, while the Rekognition API can be used to detect people and objects in photos and videos.
Chapter 8, Deep Learning on Microsoft Azure Using Python, introduces Microsoft Azure Cloud Services, focusing on the Cognitive Toolkit, which is Microsoft's alternative to TensorFlow's Emotion API, which can be used to determine the emotion of a person from a photograph of their face, and the Text-to-Speech API, which can be used to generate natural-sounding voice from text.
Chapter 9, A General Production Framework for Deep Learning-Enabled Websites, introduces the general framework to be set up for the efficient deployment of deep learning on the web in a production environment. Strategies for reducing computing resources, converting raw datasets to datasets for training deep learning models, and how to make models available for usage on the web in a minimally resource-intensive way are covered.
Chapter 10, Securing Web Apps with Deep Learning, discusses several tricks and techniques for securing websites with deep learning with Python. We present reCaptcha and Cloudflare and discuss how they are used to enhance the security of websites. We also show how to implement security mechanisms to detect malicious users on websites using deep learning on the Python backend.
Chapter 11, DIY – A Web DL Production Environment, discusses the methods by which we update models in production and how we can choose the right method according to requirements. We begin with a brief overview and then demonstrate some famous tools for creating deep learning data flows. Finally, we implement a demo of online learning, or incremental learning, to establish a method of model update in production.
Chapter 12, Creating an E2E Web App Using DL APIs and Customer Support Chatbot, introduces natural language processing and discusses how to create a chatbot for resolving general customer support queries using Dialogflow and integrate it into a Django and Flask website. We explore ways of implementing bot personalities and how to make such system resources effective. We also introduce a method for implementing a text-to-speech and speech-to-text-based user interface with Python.
Appendix, Success Stories and Emerging Areas in Deep Learning on the Web, illustrates some of the most famous websites whose products are based heavily upon leveraging the power of deep learning. This chapter also discusses some key research areas in web development that could be enhanced using deep learning. This will help you to delve even deeper into the fusion of web technologies and deep learning and will motivate you to come up with your own intelligent web applications.
This book assumes an understanding of the Python language, specifically Python 3.6 and above. It is strongly recommended to have the Anaconda distribution of Python installed on your local systems. Any Anaconda distribution with support for Python 3.6 and above is good for running the examples in this book.
In terms of hardware, this book assumes the availability of a microphone, speaker, and webcam on your computer.
Software/Hardware covered in the book
OS Requirements
Anaconda distribution of Python and other Python packages
1 GB RAM minimum, 8 GB recommended
15 GB disk space
Code editor of your choice (Sublime Text 3 recommended)
2 GB RAM
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
It is expected that you will try to implement the samples present in this book by yourself. In case you run into problems, you can reach out to us by emailing the authors – Sayak Paul ([email protected]) and Anubhav Singh ([email protected]). In case you are unable to run the samples provided in the code repo of the book, you can raise issues on the repo and we'll get back to you there!
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.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packt.com
.
Select the
Support
tab.
Click on
Code Downloads
.
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/Hands-On-Python-Deep-Learning-for-Web. 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!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: http://www.packtpub.com/sites/default/files/downloads/9781789956085_ColorImages.pdf.
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.packtpub.com/support/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.
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.
Title Page
Copyright and Credits
Hands-On Python Deep Learning for the Web
About Packt
Why subscribe?
Contributors
About the authors
About the reviewer
Packt is searching for authors like you
Dedication
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Artificial Intelligence on the Web
Demystifying Artificial Intelligence and Fundamentals of Machine Learning
Introduction to artificial intelligence and its types
Factors responsible for AI propulsion
Data
Advancements in algorithms
Advancements in hardware
The democratization of high-performance computing
ML – the most popular form of AI
What is DL?
The relation between AI, ML, and DL
Revisiting the fundamentals of ML
Types of ML
Supervised learning
Unsupervised learning
Reinforcement learning
Semi-supervised learning
Necessary terminologies
Train, test, and validation sets
Bias and variance
Overfitting and underfitting
Training error and generalization error
A standard ML workflow
Data retrieval
Data preparation
Exploratory Data Analysis (EDA) 
Data processing and wrangling
Feature engineering and extraction/selection
Modeling
Model training
Model evaluation
Model tuning 
Model comparison and selection
Deployment and monitoring
The web before and after AI
Chatbots
Web analytics
Spam filtering
Search
Biggest web-AI players and what are they doing with AI
Google Search
Google Translate
Google Assistant
Other products
Fake profiles
Fake news and disturbing content
Other uses
Amazon
Alexa
Amazon robotics
DeepLens
Summary
Using Deep Learning for Web Development
Getting Started with Deep Learning Using Python
Demystifying neural networks
Artificial neurons
Anatomy of a linear neuron
Anatomy of a nonlinear neuron
A note on the input and output layers of a neural network
Gradient descent and backpropagation
Different types of neural network
Convolutional neural networks
Recurrent neural networks
Feeding the letters to the network
Initializing the weight matrix and more
Putting the weight matrices together
Applying activation functions and the final output
Exploring Jupyter Notebooks
Installing Jupyter Notebook
Installation using pip
Installation using Anaconda
Verifying the installation
Jupyter Notebooks
Setting up a deep-learning-based cloud environment
Setting up an AWS EC2 GPU deep learning environment
Step 1: Creating an EC2 GPU-enabled instance
Step 2: SSHing into your EC2 instance
Step 3: Installing CUDA drivers on the GPU instance
Step 4: Installing the Anaconda distribution of Python
Step 5: Run Jupyter
Deep learning on Crestle
Other deep learning environments
Exploring NumPy and pandas
NumPy
NumPy arrays
Basic NumPy array operations
NumPy arrays versus Python lists
Array slicing over multiple rows and columns
Assignment over slicing
Pandas
Summary
Creating Your First Deep Learning Web Application
Technical requirements
Structuring a deep learning web application
A structure diagram of a general deep learning web application
Understanding datasets
The MNIST dataset of handwritten digits
Exploring the dataset
Creating functions to read the image files
Creating functions to read label files
A summary of the dataset
Implementing a simple neural network using Python
Importing the necessary modules
Reusing our functions to load the image and label files
Reshaping the arrays for processing with Keras
Creating a neural network using Keras
Compiling and training a Keras neural network
Evaluating and storing the model
Creating a Flask API to work with server-side Python
Setting up the environment
Uploading the model structure and weights
Creating our first Flask server
Importing the necessary modules
Loading data into the script runtime and setting the model
Setting the app and index function
Converting the image function
Prediction APIs
Using the API via cURL and creating a web client using Flask
Using the API via cURL
Creating a simple web client for the API
Improving the deep learning backend
Summary
Getting Started with TensorFlow.js
Technical requirements
The fundamentals of TF.js
What is TensorFlow?
What is TF.js?
Why TF.js?
The basic concepts of TF.js
Tensors
Variables
Operators
Models and layers
A case study using TF.js
A problem statement for our TF.js mini-project
The Iris flower dataset
Your first deep learning web application with TF.js
Preparing the dataset
Project architecture
Starting up the project
Creating a TF.js model
Training the TF.js model
Predicting using the TF.js model
Creating a simple client
Running the TF.js web app
Advantages and limitations of TF.js
Summary
Getting Started with Different Deep Learning APIs for Web Development
Deep Learning through APIs
What is an API?
The importance of using APIs
How is an API different from a library?
Some widely known deep learning APIs
Some lesser-known deep learning APIs
Choosing a deep learning API provider
Summary
Deep Learning on Google Cloud Platform Using Python
Technical requirements
Setting up your GCP account
Creating your first project on GCP
Using the Dialogflow API in Python
Creating a Dialogflow account
Creating a new agent
Creating a new intent
Testing your agent
Installing the Dialogflow Python SDK
Creating a GCP service account
Calling the Dialogflow agent using Python API
Using the Cloud Vision API in Python
The importance of using pre-trained models
Setting up the Vision Client libraries
The Cloud Vision API calling using Python
Using the Cloud Translation API in Python
Setting up the Cloud Translate API for Python
Using the Google Cloud Translation Python library
Summary
DL on AWS Using Python: Object Detection and Home Automation
Technical requirements
Getting started in AWS
A short tour of the AWS offerings
Getting started with boto3
Configuring environment variables and installing boto3
Loading up the environment variables in Python
Creating an S3 bucket
Accessing S3 from Python code with boto3
Using the Rekognition API in Python
Using the Alexa API in Python
Prerequisites and a block diagram of the project
Creating a configuration for the skill
Setting up Login with Amazon
Creating the skill
Configuring the AWS Lambda function
Creating the Lambda function
Configuring the Alexa skill
Setting up Amazon DynamoDB for the skill
Deploying the code for the AWS Lambda function
Testing the Lambda function
Testing the AWS Home Automation skill
Summary
Deep Learning on Microsoft Azure Using Python
Technical requirements
Setting up your account in Azure
A walk-through of the deep learning services provided by Azure
Object detection using the Face API and Python
The initial setup
Consuming the Face API from Python code
Extracting text information using the Text Analytics API and Python
Using the Text Analytics API from Python code
An introduction to CNTK
Getting started with CNTK
Installation on a local machine
Installation on Google Colaboratory
Creating a CNTK neural network model
Training the CNTK model
Testing and saving the CNTK model
A brief introduction to Django web development
Getting started with Django
Creating a new Django project
Setting up the home page template
Making predictions using CNTK from the Django project
Setting up the predict route and view
Making the necessary module imports
Loading and predicting using the CNTK model
Testing the web app
Summary
Deep Learning in Production (Intelligent Web Apps)
A General Production Framework for Deep Learning-Enabled Websites
Technical requirements
Defining the problem statement
Building a mental model of the project
Avoiding the chances of getting erroneous data in the first place
How not to build an AI backend
Expecting the AI part of the website to be real time
Assuming the incoming data from a website is ideal
A sample end-to-end AI-integrated web application
Data collection and cleanup
Building the AI model
Making the necessary imports
Reading the dataset and preparing cleaning functions
Slicing out the required data
Applying text cleaning
Splitting the dataset into train and test parts
Aggregating text about products and users
Creating TF-IDF vectorizers of users and products
Creating an index of users and products by the ratings provided
Creating the matrix factorization function
Saving the model as pickle
Building an interface
Creating an API to answer search queries
Creating an interface to use the API
Summary
Securing Web Apps with Deep Learning
Technical requirements
The story of reCAPTCHA
Malicious user detection
An LSTM-based model for authenticating users
Building a model for an authentication validity check
Hosting the custom authentication validation model
A Django-based app for using an API
The Django project setup
Creating an app in the project
Linking the app to the project
Adding routes to the website
Creating the route handling file in the billboard app
Adding authentication routes and configurations
Creating the login page
Creating a logout view
Creating a login page template
The billboard page template
Adding to Billboard page template
The billboard model 
Creating the billboard view 
Creating bills and adding views
Creating the admin user and testing it
Using reCAPTCHA in web applications with Python
Website security with Cloudflare
Summary 
DIY - A Web DL Production Environment
Technical requirements
An overview of DL in production methods
A web API service
Online learning
Batch forecasting
Auto ML
Popular tools for deploying ML in production
creme
Airflow
AutoML
Implementing a demonstration DL web environment
Building a predictive model
Step 1 – Importing the necessary modules
Step 2 – Loading the dataset and observing
Step 3 – Separating the target variable
Step 4 – Performing scaling on the features
Step 5 – Splitting the dataset into test and train datasets
Step 6 – Creating a neural network object in sklearn
Step 7 – Performing the training
Implementing the frontend
Implementing the backend
Deploying the project to Heroku
Security measures, monitoring techniques, and performance optimization
Summary
Creating an E2E Web App Using DL APIs and Customer Support Chatbot
Technical requirements
An introduction to NLP
Corpus
Parts of speech
Tokenization
Stemming and lemmatization
Bag of words
Similarity
An introduction to chatbots
Creating a Dialogflow bot with the personality of a customer support representative
Getting started with Dialogflow
Step 1 – Opening the Dialogflow console
Step 2 – Creating a new agent
Step 3 – Understanding the dashboard
Step 4 – Creating the intents
Step 4.1 – Creating HelpIntent
Step 4.2 – Creating the CheckOrderStatus intent
Step 5 – Creating a webhook
Step 6 – Creating a Firebase cloud function
Step 6.1 – Adding the required packages to package.json
Step 6.2 – Adding logic to index.js
Step 7 – Adding a personality to the bot
Using ngrok to facilitate HTTPS APIs on localhost
Creating a testing UI using Django to manage orders
Step 1 – Creating a Django project
Step 2 – Creating an app that uses the API of the order management system
Step 3 – Setting up settings.py
Step 3.1 – Adding the apiui app to the list of installed apps
Step 3.2 – Removing the database setting
Step 4 – Adding routes to apiui
Step 5 – Adding routes within the apiui app
Step 6 – Creating the views required
Step 6.1 – Creating indexView
Step 6.2 – Creating viewOrder
Step 7 – Creating the templates
Speech recognition and speech synthesis on a web page using the Web Speech API
Step 1 – Creating the button element
Step 2 – Initializing the Web Speech API and performing configuration
Step 3 – Making a call to the Dialogflow agent
Step 4 – Creating a Dialogflow API proxy on Dialogflow Gateway by Ushakov
Step 4.1 – Creating an account on Dialogflow Gateway
Step 4.2 – Creating a service account for your Dialogflow agent project
Step 4.3 – Uploading the service key file to Dialogflow Gateway
Step 5 – Adding a click handler for the button
Summary
Appendix: Success Stories and Emerging Areas in Deep Learning on the Web
Success stories
Quora
Duolingo 
Spotify
Google Search/Photos
Key emerging areas
Audio search
Reading comprehension
Detection of fake news on social media
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
This section introduces the definition of Artificial Intelligence (AI) and shows how AI is having an effect on the web to a great extent. It also discusses the fundamentals of machine learning in brief. This section comprises the following chapters:
Chapter 1
,
Demystifying Artificial Intelligence and Fundamentals of Machine Learning
This quote may appear extremely familiar and it's needless to say that, as a statement, it is really strongly resonant with respect to the current technological disruption. Over the recent course of time, Artificial Intelligence (AI) has been a great area of interest to almost every industry. Be it an educational company, a telecommunications firm, or an organization working in healthcare —all of them have incorporated AI to enhance their businesses. This uncanny integration of AI and several other industries only promises to get better with time and solve critical real-world problems in intelligent ways. Today, our phones can make clinical appointments for us upon our instructions, our phone cameras can tell us several human-perceived attributes of the images they capture, and our car alarm systems can detect our driving gestures and can save us from possible accidents. The examples will only get better and better and will grow as intelligent as possible with advancements in research, technology, and the democratization of computing power.
As we step into the era of Software 2.0, it is extremely important to understand why a technology that has existed since the 1950s is making most of the headlines in recent times. Yes! Artificial intelligence was born in the 1950s when a handful of computer scientists and mathematicians such as Alan Turing started to think about whether machines could think and whether they could be empowered with intelligence so that they can answer questions on their own without being explicitly programmed.
Soon after this inception, the term artificial intelligence was first coined by John McCarthy in 1956 in an academic conference. From the question "Can machines think?" (proposed by Turing in his paper, entitled Computing Machinery and Intelligence) around 1950 to the current day in the 21st century, the world of AI has shown some never-seen-before results that we could never have even thought of.
Today, it is almost impossible to think of a day without using the web. It has easily become one of our fundamental necessities. Our favorite search engines can directly answer our questions rather than give us a list of relevant links. They can analyze online text and detect their intent and summarize their content. All of this is possible because of AI.
This book aims to be a hands-on guide to the readers on how they can use AI techniques such as deep learning to make intelligent web applications based on computer vision, natural language processing, security, and lots more. This chapter provides the readers with a quick refresher on AI and its different types and the basic concepts of ML, and introduces some of the biggest names in the industry and what they are doing by fusing AI and web technologies. We will be covering the following aspects:
Introduction to AI and its different types
Machine Learning
(
ML
): The most popular AI
A brief introduction to
Deep Learning
(
DL
)
The relationship between AI, ML, and DL
Fundamentals of ML
The web before and after AI
The biggest web-AI players and what they are doing
In a simpler sense, artificial intelligence is all about giving machines the ability to perform intelligently. For example, many of us can play chess. Essentially, we do this first by learning the fundamentals of playing the game and then we engage ourselves in actually playing the game with others. But can machines do this? Can machines learn on their own and play the game of chess with us?
AI attempts to make this possible by giving us the power to synthesize what we call intelligence in terms of some rules and instill it into machines. Machines as mentioned here can be anything that can compute. For example, it could be software or a robot.
There are actually several types of AI. The popular ones are the following:
Fuzzy systems
Expert systems
ML systems
The final type sounds the most familiar here. We will get to it in the next section. But before we proceed with it, it is a good time to take a look at some of the points that enable the AI advancements we are witnessing today.
The major factors that are driving the AI force are the following:
Data
Algorithmic advancements
Computer hardware advancements
The democratization of high-performance computing
The amount of data we have today is enormous—as Hal Varian, Chief Economist at Google, put it in 2016:
That's a lot of data. As the number of digital devices grows, this volume of data will only continue to grow exponentially. Gone are the times when a running car only displayed the speed on the speedometer. We're in an age where every part of the car can be made to produce logs at every split second, enabling us to entirely reconstruct any moment of the car's life.
The more a person gets to learn from life, the wiser the person becomes, and the better they can predict outcomes of events in the future. Analogically with machines, the greater the amount of (quality) data that a piece of software gets to train upon, the better it gets at predicting future unseen data.
In the last few years, the availability of data has grown manifold due to various factors:
Cheaper storage
Higher data transmission rates
Availability of cloud-based storage solutions
Advanced sensors
The Internet of Things
An increase in the various forms of digital electronic devices
Increased usage of websites and native apps
There are more digital devices now than ever. They are all equipped with systems that can generate logs at all times and transmit them over the internet to the companies that manufacture them or any other vendor that buys that data. Also, a lot of logs are created by the websites or apps people use. All of these are easily stored in cloud-based storage solutions or in physical storage of high storage capacity, which are now cheaper than before.
If you look around yourself, you will probably be able to see a laptop on which you regularly use several pieces of software and websites—all of which may be collecting data on every action you perform on them. Similarly, your phone acts as such a data-generating device. With a television with several channels provided by your television service provider—both the service provider and the channel provider are collecting data about you to serve you better and to improve their products. You can only imagine the massive amount of data a single person generates on a daily basis, and there are billions of us on this planet!
An algorithm is an unambiguous sequence of steps that leads to the solution of a given problem. Over time, with the expansion of science and human understanding of the laws of nature by the aid of mathematics, algorithms have seen improvements. More often than not, nature has inspired solutions to complex problems. A neural network is probably the most talked-about, nature-inspired algorithm in the present day.
When computer logic began with multiple if-else ladders, no one would ever have thought that one day we'd have computer programs that would learn to produce results similar to the if-else ladder without the need to write conditions manually. What's more, we have computer programs today that generate other programsthat can simulate AI!
Surely, with each passing day, algorithms developed by humans and now, by machines too, are getting smarter and more powerful at performing their tasks. This has directly impacted the rise of neural networks, which, in their rudimentary form, seem to be a time-consuming super-nesting of loops to solve matrices and vector arithmetic problems.
When Intel revealed its first Dynamic RAM module in 1970, it was capable of holding 1 KB of data. Approximately 50 years later, we've 128 GB RAM modules available in the market. That's nearly 1.28 x 108 times as much memory space.
A similar trend has been exhibited by hard disks. With the first hard disk for personal computers being able to store a precious 5 megabytes, 2016 saw Seagate announcing a 60-terabyte storage on a solid-state drive. That's a 1.2 x 107 fold increase.
But we've only yet talked about direct individual computing comparisons, without considering the effect of technological growth since the first computers were introduced. Today, with the advent of cloud computing, it's become common to hear someone talking about unlimited cloud storage.
AI has greatly benefited from this exponential increase in computing speed and data storage.
With the reducing costs of commodity hardware and their increasing performance capabilities, high-performance computing is not something exclusive to tech giants these days. Today, it is very easily possible for any single person to set up for their personal use a network of computing devices to facilitate high-performance computing if they're not already satisfied with the exceptional performance that can be delivered through single devices. However, investing in hardware is not the only way of availing high-performance computing. The emergence of cloud-based computing solutions has resulted in very high-speed computing infrastructure available with click-deploy methods. Users can, at any moment, launch a cloud-based instance over the network and run their performance-intensive software on it at minimal charges.
With high-performance computing becoming readily available to individual developers, the development of AI solutions has come into the hands of a wide community of developers. This has led to a boom in the number of creative and research-based applications of AI.
Let's now unravel the most popular form of AI as of the time of writing and discuss some important concepts regarding it.
Without taking any mathematical notations or too many theoretical details, let's try to approach the term Machine Learning (ML) from an intuitive perspective. For doing this, we will have to take a look at how we actually learn. Do you recollect, at school, when we were taught to identify the parts of speech in a sentence? We were presented with a set of rules to identify the part of the speeches in a sentence. We were given many examples and our teachers in the first place used to identify the parts of speeches in sentences for us to train us effectively so that we could use this learning experience to identify the parts of speeches in sentences that were not taught to us. Moreover, this learning process is fundamentally applicable to anything that we learn.
What if we could similarly train the machines? What if we could program them in such a way that they could learn from experiences and could start answering questions based on this knowledge? Well, this has already been done, and, knowingly or unknowingly, we are all taking the benefits yielded by this. And this is exactly what ML is when discussed intuitively. For a more formal, standard understanding, let's take a look at the following definition by Tom Mitchell in his book, Machine Learning:
The preceding definition is a more precise version of what we just discussed about ML from an intuitive perspective. It is important to note here that most AI wizardry that we see today is possible due to this form of AI.
We now have a fair idea of what ML is. Now, we will move to the next section, which discusses the most powerful subfield of ML—DL. We will not go into the bone-breaking mathematical details. Instead, we will break it down intuitively, as in this section.
Now comes the most exciting part and probably the hottest technical term of this century. Reality apart, we now understand the learning to some extent, so let's get to the first part of the term deep learning—deep.
DL is a type of machine learning but it is purely based on neural networks. We will take a look at neural networks too but in the next chapter. The basic objective of any machine learning system is to learn useful representations of the data given to it. But what makes DL different? It turns out that DL systems treat data as a representation of layers. For example, an image can be treated as a representation of layers of varying properties such as edges, contours, orientation, texture, and gradients. The following diagram from the book, Deep Learning with Python, by François Chollet captures this idea nicely:
In the preceding diagram, a DL system is being employed to classify an image of a hand-written digit. The system takes the image of the handwritten digit as its input and tries to learn its underlying representations. In the first layer, the system learns generic features such as strokes and lines. As the layers increase, it learns about the features that are more specific to the given image. The more the number of layers, the deeper the system gets. Let's take a look at the following definition, which is given by François Chollet in his book, Deep Learning with Python:
The definition quite aptly captures all of the necessary ingredients of DL and beautifully introduces the concept of treating data as a layered representation. So, a DL system, in a broad sense, breaks down the data into simple representations in a layered fashion, and to learn these representations, it often makes use of many layers (which is referred to as deep). We will now take a look at the big picture, which tells us how AI, ML, and DL are related to each other.
To make sure that our basics are clear regarding the distinction between AI, ML, and DL, let's refer to the following diagram, which elegantly captures the relationship between these three big names:
The diagram is quite self-explanatory and it has been referred to in many books in the field of DL. Let's try drawing an interesting conclusion from this diagram.
The statement may appear slightly confusing at first glance, but if we got our basics right, then this captures the distinction between AI, ML, and DL beautifully. We will proceed toward revisiting some of the necessary ML terminologies and concepts that will be required in the latter parts of this book.
