Artificial Intelligence Programming with Python from Zero to Hero 1st Edition Perry Xiao all chapter instant download
Artificial Intelligence Programming with Python from Zero to Hero 1st Edition Perry Xiao all chapter instant download
com
https://ebookmass.com/product/artificial-intelligence-
programming-with-python-from-zero-to-hero-1st-edition-perry-
xiao/
OR CLICK HERE
DOWLOAD NOW
https://ebookmass.com/product/prolog-programming-for-artificial-
intelligence-4ed-edition-ivan-bratko/
ebookmass.com
https://ebookmass.com/product/swarm-intelligence-an-approach-from-
natural-to-artificial-1st-edition-kuldeep-singh-kaswan/
ebookmass.com
https://ebookmass.com/product/python-for-artificial-intelligence-a-
comprehensive-guide-elsherif-h/
ebookmass.com
https://ebookmass.com/product/etextbook-pdf-for-we-the-people-core-
twelfth-edition-12th-edition/
ebookmass.com
Handbook of Robotic and Image-Guided Surgery Mohammad H.
Abedin-Nasab (Editor)
https://ebookmass.com/product/handbook-of-robotic-and-image-guided-
surgery-mohammad-h-abedin-nasab-editor/
ebookmass.com
https://ebookmass.com/product/mathematical-techniques-of-fractional-
order-systems-azar-a-t-et-al-eds/
ebookmass.com
https://ebookmass.com/product/lavender-and-lust-wild-blooms-series-
book-9-jaclyn-combe-wild-blooms/
ebookmass.com
https://ebookmass.com/product/diagnostic-ultrasound-head-and-neck-2nd-
edition-ahuja-mbbs-bom-md-bom-frcr-fhkcr-fhkam-radiology/
ebookmass.com
https://ebookmass.com/product/xero-a-comprehensive-guide-for-
accountants-and-bookkeepers-1st-edition-amanda-aguillard/
ebookmass.com
Junior Puzzle Book Alligator Books
https://ebookmass.com/product/junior-puzzle-book-alligator-books/
ebookmass.com
Artificial Intelligence
Programming with Python®
Artificial Intelligence
Programming with
Python®
From Zero to Hero
Perry Xiao
Copyright © 2022 by John Wiley & Sons, Inc. All rights reserved.
ISBN: 978-1-119-82086-4
ISBN: 978-1-119-82094-9 (ebk)
ISBN: 978-1-119-82096-3 (ebk)
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted
under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission
of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clear-
ance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web
at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008,
or online at http://www.wiley.com/go/permission.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or war-
ranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all
warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be
created or extended by sales or promotional materials. The advice and strategies contained herein may not
be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in
rendering legal, accounting, or other professional services. If professional assistance is required, the services
of a competent professional person should be sought. Neither the publisher nor the author shall be liable for
damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses
the information the organization or Website may provide or recommendations it may make. Further, readers
should be aware the Internet Websites listed in this work may have changed or disappeared between when
this work was written and when it is read.
For general information on our other products and services or for technical support, please contact our Cus-
tomer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993
or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic formats. For more information about Wiley products, visit our web site at
www.wiley.com.
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc.
and/or its affiliates, in the United States and other countries, and may not be used without written permis-
sion. Python is a registered trademark of Python Software Foundation. All other trademarks are the property
of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned
in this book.
I would also like to dedicate this book to Grace Qing Wang, who sadly
passed away during the course of writing this book. Grace Qing Wang was a
young, energetic professional woman who was passionate about innovation
and artificial intelligence in education. She was also a collaborator and a
good friend. Through Grace I have made many professional connections
that were very beneficial to my career.
About the Author
Dr. Perry Xiao is a professor and course director at the School of Engineering,
London South Bank University in London, United Kingdom. He got his BEng
degree in opto-electronics, MSc degree in solid-state physics, and PhD degree
in photophysics. He is a charted engineering (CEng), a Fellow (FIET) from
the Institution of Engineering and Technology (IET), and a Senior Fellow
(SFHEA) from the Higher Education Academy (HEA). He has been teaching
electronics, software, computer networks, and telecommunication subjects
at both the undergraduate level and the postgraduate level for nearly two
decades. He also supervises BEng final project students and MSc project
students every year. His main research interest is to develop novel infrared
and electronic sensing technologies for skin bioengineering applications and
industrial nondestructive testing (NDT). To date, he has finished more than
12 PhD student supervisions, obtained two UK patent applications, published
more than 100 scientific papers, been editorial reviewer for nine journals, and
generated nearly £1 million in research grants.
He is also a director and cofounder of Biox Systems Ltd., UK, a university
spin-o ff company that designs and manufactures state-o f-t he-a rt skin
measurement instruments, AquaFlux and Epsilon, which have been used in
more than 200 organizations worldwide, including leading cosmetic com-
panies, universities, research institutes, and hospitals.
vii
About the Technical Editors
Dr. Weiheng Liao, DPhil (Oxon), is a computer scientist and technology entre-
preneur in AI. He has authored and co-authored a number of influential papers
in top journals and conferences and is the visiting scholar of several research
universities. His interests include machine learning, AutoML, deep learning,
explainable AI, natural language processing, and their applications in finance
and investment. He cofounded YouShore, one of the world’s first teams to
employ deep NLP to analyze social media data, to extract alternative data, and
to construct alpha signals.
If you want to know more about his recent work, please visit w w w
.madebydata.com.
ix
Acknowledgments
xi
Contents at a Glance
Prefacexxiii
Part I Introduction
Chapter 1 Introduction to AI 3
Chapter 2 AI Development Tools 23
Part II Machine Learning and Deep Learning
Chapter 3 Machine Learning 53
Chapter 4 Deep Learning 117
Part III AI Applications
Chapter 5 Image Classification 201
Chapter 6 Face Detection and Face Recognition 265
Chapter 7 Object Detections and Image Segmentations 337
Chapter 8 Pose Detection 433
Chapter 9 GAN and Neural-Style Transfer 465
Chapter 10 Natural Language Processing 491
Chapter 11 Data Analysis 543
Chapter 12 Advanced AI Computing 613
Index659
xiii
xiv Contents at a Glance
Prefacexxiii
Part I Introduction
Chapter 1 Introduction to AI 3
1.1 What Is AI? 3
1.2 The History of AI 5
1.3 AI Hypes and AI Winters 9
1.4 The Types of AI 11
1.5 Edge AI and Cloud AI 12
1.6 Key Moments of AI 14
1.7 The State of AI 17
1.8 AI Resources 19
1.9 Summary 21
1.10 Chapter Review Questions 22
Chapter 2 AI Development Tools 23
2.1 AI Hardware Tools 23
2.2 AI Software Tools 24
2.3 Introduction to Python 27
2.4 Python Development Environments 30
2.4 Getting Started with Python 34
2.5 AI Datasets 45
2.6 Python AI Frameworks 47
2.7 Summary 49
2.8 Chapter Review Questions 50
Part II Machine Learning and Deep Learning
Chapter 3 Machine Learning 53
3.1 Introduction 53
3.2 Supervised Learning: Classifications 55
xv
xvi Contents
Scikit-Learn Datasets 56
Support Vector Machines 56
Naive Bayes 67
Linear Discriminant Analysis 69
Principal Component Analysis 70
Decision Tree 73
Random Forest 76
K-Nearest Neighbors 77
Neural Networks 78
3.3 Supervised Learning: Regressions 80
3.4 Unsupervised Learning 89
K-means Clustering 89
3.5 Semi-supervised Learning 91
3.6 Reinforcement Learning 93
Q-Learning 95
3.7 Ensemble Learning 102
3.8 AutoML 106
3.9 PyCaret 109
3.10 LazyPredict 111
3.11 Summary 115
3.12 Chapter Review Questions 116
Chapter 4 Deep Learning 117
4.1 Introduction 117
4.2 Artificial Neural Networks 120
4.3 Convolutional Neural Networks 125
4.3.1 LeNet, AlexNet, GoogLeNet 129
4.3.2 VGG, ResNet, DenseNet, MobileNet,
EffecientNet, and YOLO 140
4.3.3 U-Net 152
4.3.4 AutoEncoder 157
4.3.5 Siamese Neural Networks 161
4.3.6 Capsule Networks 163
4.3.7 CNN Layers Visualization 165
4.4 Recurrent Neural Networks 173
4.4.1 Vanilla RNNs 175
4.4.2 Long-Short Term Memory 176
4.4.3 Natural Language Processing and Python
Natural Language Toolkit 183
4.5 Transformers 187
4.5.1 BERT and ALBERT 187
4.5.2 GPT-3 189
4.5.3 Switch Transformers 190
4.6 Graph Neural Networks 191
4.6.1 SuperGLUE 192
4.7 Bayesian Neural Networks 192
Contents xvii
The year 2020 was a year of turmoil, conflicts, and division. The most significant
event was no doubt the COVID-19 pandemic, which was, and still is, raging
in more than 200 countries and affecting the lives of hundreds of millions of
people. I spent a good part of the year working from home. There are many
disadvantages of remote working; however, it does have at least one advantage:
it saved me at least two hours a day traveling to and from work. This gave me
more time to think about, to plan, and to propose this book.
I am absolutely fascinated with artificial intelligence, and I have read many
artificial intelligence books. But most of the books are heavily focused on the
mathematics of artificial intelligence, which makes them difficult to understand
for people without mathematics or computer science backgrounds. I have
always wanted to write a book that could make it easier to get into the artificial
intelligence field for beginners—people from all different disciplines. Thanks
to the countless researchers and developers around the world and their open
source code, particularly Python-based open source code, it is much easier to
use artificial intelligence now than 10 years ago. Through this book, you will
find that you can do amazing things with just a few lines of code, and in some
cases, you don’t need to code at all.
I am a big fan of open source, and for a research field as controversial as
artificial intelligence, it is better for everyone to work together. So, I want to
express my ultimate gratitude to those who made their work available for
the benefit of others.
We are living in an era of digital revolutions and digital technologies such
as artificial intelligence, the Internet of Things, Industry 4.0, 5G technologies,
digital twin, cybersecurity, big data, cloud computing, blockchains, and, on the
horizon, quantum computing. They are all being developed at a breathtaking
xxiii
xxiv Preface
speed. In the future, the Internet of Things will provide a means to connect all
things around us and to use sensors to collect data. The industry version of the
Internet of Things is called Industry 4.0, which will connect all sorts of things for
manufacturers. Digital twin is a digital representation of a process, product, or
service updated from real-time data. With digital twin, we can predict problems
before they even occur, prevent downtime, develop new opportunities for the
future through simulations. 5G technologies will provide a means for fast and
low-latency communications for the data. Cybersecurity will provide a means
to protect the data. Big data will provide a means to analyze the data in large
quantity. Cloud computing will provide the storage, display, and analysis of
the data remotely, in the cloud. Blockchains will provide traceability to the data
through distributed ledgers. Quantum computing will make some of the com-
putation faster, in fact, many orders of magnitude faster. Artificial intelligence
will be right at the heart of all the technologies, which allows us to analyze the
data intelligently. As you can see, all these digital technologies are going to
become intertwined to make us work better and live smarter.
That is why I have always said to my students, you can change your future.
Your future is in your hands. The key is learning, even after graduation.
Learning is a lifelong mission. In today’s ever-evolving world, with all the
quickly developing digital technologies, you need to constantly reinvent your-
self; you will need to learn everything and learn anything. The disadvantage
of fast-changing technologies is that you will need to learn all the time, but
the advantage is no one has any more advantages than you; you are on the
same starting line as everyone else. The rest is up to you!
I believe artificial intelligence will be just a tool for everyone in the future,
just like software coding is today. Artificial intelligence will no doubt affect
every aspect of our lives and will fundamentally change the way we live, how
we work, and how we socialize. The more you know about artificial intelli-
gence and the more involved you are in artificial intelligence, the better you
can transform your life.
Many successful people are lifelong learners. American entrepreneur and
business magnate Elon Musk is a classic example. As the world’s richest man,
he learned many things by himself, from computer programming, Internet,
finance, to building cars and rockets. British comedian Lee Evans once said
that by the end of the day, if you have learned something new, then it is a good
day. I hope you will have a good day every day and enjoy reading this book!
Professor Perry Xiao
July 2021, London
Preface xxv
Part II
Chapter 3: Machine Learning
Chapter 4: Deep Learning
Part III
Chapter 5: Image Classifications
Chapter 6: Face Detection and Recognition
Chapter 7: Object Detections and Image Segmentations
Chapter 8: Pose Detection
Chapter 9: GAN and Neural-Style Transfer
Chapter 10: Natural Language Processing
Chapter 11: Data Analysis
Chapter 12: Advanced AI Computing
Example Code
All the example source code is available on the website that accompanies this
book.
Python Pocket Reference: Python in Your Pocket, 5th edition, Mark Lutz,
O’Reilly Media, 9 Feb. 2014.
ISBN-10 : 1449357016
ISBN-13 : 978-1449357016
A Beginner’s Python Tutorial (Wikibooks)
https://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial
Python Programming (Wikibooks)
https://en.wikibooks.org/wiki/Python_Programming
I
Introduction
In This Part:
Chapter 1: Introduction to AI
Chapter 2: AI Development Tools
Part I gives a bird’s-eye overview of artificial intelligence (AI) and AI development
resources.
CHAPTER
Introduction to AI
“There is no reason and no way that a human mind can keep up
with an artificial intelligence machine by 2035.”
—Gray Scott (American futurist)
3
4 Part I ■ Introduction
For more information, see the John McCarthy’s 2004 paper titled, “What Is
Artificial Intelligence?”
https://homes.di.unimi.it/borghese/Teaching/AdvancedIntelligent
Systems/Old/IntelligentSystems_2008_2009/Old/IntelligentSystems_
2005_2006/Documents/Symbolic/04_McCarthy_whatisai.pdf
You may not be aware that AI has already been widely used in many aspects of
our lives. Personal assistants such as Amazon’s Alexa, iPhone’s Siri, Microsoft’s
Cortana, and Google Assistant all rely on AI to understand what you have said
and follow the instructions to perform tasks accordingly.
Online entertainment services such as Spotify and Netflix also rely on AI
to figure out what you might like and recommend songs and movies. Other
services such as Google, Facebook, Amazon, and eBay analyze your online
activities to deliver targeted advertisements. My wife once searched Arduino
boards at work during the day, and in the evening, after she got home, no matter
which websites she visited, ads for Arduino boards kept popping up!
Have you ever used the SwiftKey program on your phone or Grammarly on
your computer? They are also AI.
AI has also been used in healthcare, manufactoring, driverless cars, finance,
agriculture, and more. In a recent study, researchers from Google Health and
Imperial College London developed an algorithm that outperformed six human
Chapter 1 ■ Introduction to AI 5
Figure 1.2: The bombe machine (left) and the Enigma machine (right)
(Source: https://en.wikipedia.org/wiki/Cryptanalysis_of_the_Enigma)
computer and which is a human. The interrogator is limited to using the responses
to written questions to make the determination. The Turing test has since been
used to test a machine’s intelligence to see if it is equivalent to a human. To
date, no computer has passed the Turing test.
Figure 1.3: The famous Turing test, also called the imitation game. Player C, the interrogator, is
trying to determine which player—A or B—is a computer and which is a human.
In 1739 the interest arising from this gift was withdrawn at his
request and paid to the Springfield Friends to help them build their
meeting house.[686]
In response to the yearly meeting’s urgent request of 1746 and
1750,[687] we have their action recorded in this minute of the year
1754.
[Sidenote: Report
According to a minute of the advice of the required on state
Last Yearly Meeting concerning the settling of of legacies]
schools in the country, it is agreed for the
encouragement thereof that the several and respective clerks
of the monthly meetings belonging to this quarterly meeting
do inquire and bring in a true report of all legacies, donations
or estates which have been heretofore given to their
respective meetings and of the uses to which the moneys
arising therefrom are applied, and bring the account thereof to
our next meeting.[688]
His salary for the first year is not known, but the minutes a year
later give some clue as to the amount paid.
Agreed at this meeting that Benjamin Clift teach school a
year, beginning this 20th day of this 9th month; and to have
£12/00/00.[693]
Friends
signified to this meeting in writing that the meeting appointed
last 7th month to be kept at the said Richard’s schoolhouse
was duly and religiously kept and further requested to be
permitted to keep an afternoon meeting ... which is allowed of
and to be at four o’clock.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com