Deep Learning Pipeline: Building A Deep Learning Model With Tensorflow 1St Edition Hisham El-Amir
Deep Learning Pipeline: Building A Deep Learning Model With Tensorflow 1St Edition Hisham El-Amir
com
https://textbookfull.com/product/deep-learning-pipeline-
building-a-deep-learning-model-with-tensorflow-1st-edition-
hisham-el-amir/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/learning-tensorflow-a-guide-to-
building-deep-learning-systems-1st-edition-tom-hope/
textbookfull.com
https://textbookfull.com/product/deep-learning-with-python-develop-
deep-learning-models-on-theano-and-tensorflow-using-keras-jason-
brownlee/
textbookfull.com
https://textbookfull.com/product/deep-learning-on-windows-building-
deep-learning-computer-vision-systems-on-microsoft-windows-thimira-
amaratunga/
textbookfull.com
https://textbookfull.com/product/applied-neural-networks-with-
tensorflow-2-api-oriented-deep-learning-with-python-orhan-gazi-yalcin/
textbookfull.com
https://textbookfull.com/product/deep-learning-with-python-1st-
edition-francois-chollet/
textbookfull.com
https://textbookfull.com/product/deep-learning-with-r-1st-edition-
francois-chollet/
textbookfull.com
https://textbookfull.com/product/deep-learning-with-pytorch-1st-
edition-eli-stevens/
textbookfull.com
Deep Learning
Pipeline
Building a Deep Learning Model
with TensorFlow
—
Hisham El-Amir
Mahmoud Hamdy
Deep Learning Pipeline
Building a Deep Learning
Model with TensorFlow
Hisham El-Amir
Mahmoud Hamdy
Deep Learning Pipeline: Building a Deep Learning Model with TensorFlow
Hisham El-Amir Mahmoud Hamdy
Jizah, Egypt Jizah, Egypt
Part I: Introduction����������������������������������������������������������������������1
Chapter 1: A Gentle Introduction����������������������������������������������������������3
Information Theory, Probability Theory, and Decision Theory�������������������������������4
Information Theory������������������������������������������������������������������������������������������4
Probability Theory��������������������������������������������������������������������������������������������6
Decision Theory�����������������������������������������������������������������������������������������������8
Introduction to Machine Learning�����������������������������������������������������������������������10
Predictive Analytics and Its Connection with Machine learning��������������������11
Machine Learning Approaches����������������������������������������������������������������������12
From Machine Learning to Deep Learning����������������������������������������������������������19
Lets’ See What Some Heroes of Machine Learning Say About the Field������������19
Connections Between Machine Learning and Deep Learning�����������������������20
Difference Between ML and DL���������������������������������������������������������������������21
Why Should We Learn About Deep Learning (Advantages of
Deep learning)?���������������������������������������������������������������������������������������������23
Disadvantages of Deep Learning (Cost of Greatness)�����������������������������������24
Introduction to Deep Learning����������������������������������������������������������������������������25
Machine Learning Mathematical Notations��������������������������������������������������������28
Summary������������������������������������������������������������������������������������������������������������36
iii
Table of Contents
iv
Table of Contents
Evaluate Algorithms���������������������������������������������������������������������������������������72
Improve Results���������������������������������������������������������������������������������������������73
Fast Preview of the TensorFlow Pipeline������������������������������������������������������������74
Tensors—the Main Data Structure����������������������������������������������������������������75
First Session��������������������������������������������������������������������������������������������������76
Data Flow Graphs������������������������������������������������������������������������������������������78
Tensor Properties������������������������������������������������������������������������������������������81
Summary������������������������������������������������������������������������������������������������������������83
v
Table of Contents
Tidy Data�����������������������������������������������������������������������������������������������������������117
Divide and Conquer�������������������������������������������������������������������������������������������118
Tabular Data������������������������������������������������������������������������������������������������������119
Quantitative vs. Qualitative Data�����������������������������������������������������������������119
Example—the Titanic����������������������������������������������������������������������������������119
Divide and Conquer�������������������������������������������������������������������������������������121
Making a Checkpoint�����������������������������������������������������������������������������������122
The Four Levels of Data�������������������������������������������������������������������������������122
The Nominal Level���������������������������������������������������������������������������������������123
The Ordinal Level�����������������������������������������������������������������������������������������125
Quick Recap and Check�������������������������������������������������������������������������������129
The Interval Level����������������������������������������������������������������������������������������130
Examples of Interval Level Data������������������������������������������������������������������130
What Data Is Like at the Interval Level��������������������������������������������������������131
Mathematical Operations Allowed for Interval��������������������������������������������131
The Ratio Level��������������������������������������������������������������������������������������������134
Summarizing All Levels Table 5-1����������������������������������������������������������������136
Text Data�����������������������������������������������������������������������������������������������������������137
What Is Text Processing and What Is the Level of Importance of
Text Processing?�����������������������������������������������������������������������������������������137
IMDB—Example������������������������������������������������������������������������������������������138
Images Data������������������������������������������������������������������������������������������������139
Summary����������������������������������������������������������������������������������������������������������144
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
Adadelta������������������������������������������������������������������������������������������������������350
RMSprop������������������������������������������������������������������������������������������������������351
Adam�����������������������������������������������������������������������������������������������������������352
Nadam (Adam + NAG)���������������������������������������������������������������������������������353
Choosing the Learning Rate������������������������������������������������������������������������������354
Dropout Layers and Regularization�������������������������������������������������������������������357
Normalization Techniques���������������������������������������������������������������������������������359
Batch Normalization������������������������������������������������������������������������������������360
Weight Normalization����������������������������������������������������������������������������������361
Layer Normalization������������������������������������������������������������������������������������362
Instance Normalization��������������������������������������������������������������������������������363
Group Normalization������������������������������������������������������������������������������������364
Summary����������������������������������������������������������������������������������������������������������365
xi
Table of Contents
xii
Table of Contents
Transfer Learning����������������������������������������������������������������������������������������������460
What Is a Pretrained Model, and Why Use It?����������������������������������������������461
How to Use a Pretrained Model?�����������������������������������������������������������������462
Ways to Fine-Tune the Model����������������������������������������������������������������������463
Pretrained VGG19�����������������������������������������������������������������������������������������464
Summary����������������������������������������������������������������������������������������������������������469
Index�������������������������������������������������������������������������������������������������537
xiii
About the Authors
Hisham El-Amir is a data scientist with expertise in machine learning,
deep learning, and statistics. He currently lives and works in Cairo, Egypt.
In his work projects, he faces challenges ranging from natural language
processing (NLP), behavioral analysis, and machine learning to distributed
processing. He is very passionate about his job and always tries to stay
updated about the latest developments in data science technologies,
attending meetups, conferences, and other events.
xv
About the Technical Reviewer
Vishwesh Ravi Shrimali graduated in 2018 from BITS Pilani, where
he studied mechanical engineering. Since then, he has been working
with BigVision LLC on deep learning and computer vision, and is also
involved in creating official OpenCV courses. He has a keen interest
in programming and AI, and has applied that interest in mechanical
engineering projects. He has also written multiple blogs on OpenCV and
deep learning on LearnOpenCV, a leading blog on computer vision. He has
also co-authored Machine Learning for OpenCV4 (2nd edition). When he
is not writing blogs or working on projects, he likes to go on long walks or
play his acoustic guitar.
xvii
Introduction
Artificial intelligence (AI) is the field of embeddings human thinking into
computers: in other words, creating an artificial brain that mimics the
functions of the biological brain. Whatever the human can do intelligently
is now required to be moved into machines. First-generation AI focuses
on problems that can be formally described by humans. Using AI, steps
for doing something intelligent are described in a form of instructions
that machines follow. Machines follow humans without changes. These
features are characteristic of the first era of AI.
Humans can fully describe only simple problems such as chess,
and fail to describe more complicated problems. In chess, the problem
can be simply explained by representing the board as a matrix of size
8×8, describing each piece and how it moves and describing the goals.
Machines will be restricted to those tasks formally described by humans.
By programming such instructions, machines can play chess intelligently.
Machine intelligence is now artificial. The machine itself is not intelligent,
but humans have transferred their intelligence to the machine in the
form of several static lines of code. “Static” means that the behavior is the
same in all cases. The machine, in this case, is tied to the human and can’t
work on its own. This is like a master–slave relationship. The human is the
master and the machines are the slaves, which just follow the human’s
orders and no more.
To make the machine able to recognize objects, we can give it previous
knowledge from experts in a way the machine can understand. Such
knowledge-based systems form the second era of AI. One of the challenges
in such systems is how to handle uncertainty and unknowns. Humans
xix
Introduction
The Goal
Deep learning is a branch of machine learning where you model the world
in terms of a hierarchy of concepts. This pattern of learning is similar to
the way a human brain learns, and it allows computers to model complex
concepts that often go unnoticed in other traditional methods of modeling.
Hence, in the modern computing paradigm, deep learning plays a vital
role in modeling complex real-world problems, especially by leveraging
the massive amount of unstructured data available today.
Because of the complexities involved in a deep learning model,
many times it is treated as a black box by people using it. However, to
derive the maximum benefit from this branch of machine learning,
one needs to uncover the hidden mystery by looking at the science and
mathematics associated with it. In this book, great care has been taken
to explain the concepts and techniques associated with deep learning
from a mathematical as well as a scientific viewpoint. Also, the first
chapter is totally dedicated to building the mathematical base required
to comprehend deep learning concepts with ease. TensorFlow has been
chosen as the deep learning package because of its flexibility for research
purposes and its ease of use. Another reason for choosing TensorFlow is its
capability to load models with ease in a live production environment using
its serving capabilities.
In summary, Deep Learning Pipeline should provide practical expertise
so you can learn deep learning pipeline from scratch in such a way that
you can deploy meaningful deep learning solutions. This book will
allow you to get up to speed quickly using TensorFlow and to optimize
different deep learning architectures. All the practical aspects of deep
xx
Introduction
learning that are relevant in any industry are emphasized in this book.
You will be able to use the prototypes demonstrated to build new deep
learning applications. The code presented in the book is available in the
form of iPython notebooks and scripts that allow you to try out examples
and extend them in interesting ways. You will be equipped with the
mathematical foundation and scientific knowledge to pursue research in
this field and give back to the community.
All code in the book is implemented using Python. Because native
Python is complex for handling images, multiple libraries are used to
help to produce an efficient implementation for applications across the
chapters.
Prerequisites
Python and all the deep learning tools mentioned in the book, from
IPython to TensorFlow to model that you will use, are free of charge
and can be freely downloaded from the Internet. To run the code that
accompanies the book, you need a computer that uses a Windows, Linux,
or Mac OS operating system. The book will introduce you step-by-step to
the process of installing the Python interpreter and all the tools and data
that you need to run the examples.
xxi
Introduction
C
hapters
• Chapter 1: A gentle introduction—This chapter provides
the big picture that shows readers what is the field that
the book describes; introduction to this field; and the
mathematical equations and notations that describe
how machine learning works.
xxii
Introduction
xxiii
Introduction
xxiv
Introduction
xxv
PART I
Introduction
CHAPTER 1
A Gentle Introduction
If you have ever tried to read a deep learning or even machine learning
book, you will find that these books define machine learning (ML) as the
science that teaches machines how to carry out tasks by themselves. That’s
a simple idea if you think of it this way, but the complexity is in the details
of this mysterious science; it’s within the black art of how these machines
can act like humans.
Because you are reading this book now, you are probably one of the
following:
Upon starting the book, we have to make sure that you know where
machine learning and deep learning come from and that's by describing
the three theories: information, probability, and decision theory. After
that, we will illustrate what is machine learning and what is deep learning,
and also the evolution from machine learning to deep learning.
1. Information theory
2. Probability theory
3. Decision theory
Information Theory
In this section, we start by answering a very good question: what are the
components of the deep learning approach?
The first thing you do in any project is to get and prepare your dataset.
And here, we start these theories by introducing some additional concepts
from the field of information theory, which will also prove useful in our
4
Chapter 1 A Gentle Introduction
5
Chapter 1 A Gentle Introduction
Probability Theory
As deep learning is concerned with learning from data, it has to learn the
pattern behind these data. And as you learn about this field of science,
you will find yourself facing the key concept of uncertainty. While you are
building a deep learning algorithm that should learn from and about a
given dataset, you will find the most famous fact in the deep learning and
machine learning world, which is the following:
• The model is too small for the data, and that means that
it cannot capture all the knowledge or the patterns from
the dataset.
6
Chapter 1 A Gentle Introduction
So, after understanding the problems you have to face that make your
model unable to perform accurately, you have another question: how can I
overcome these obstacles and make my model achieve the desired accuracy?
The answer is behind the art of statistics, as before the invention of
neural networks, statisticians used to make prediction based on a dataset.
Statisticians used what are called distributions to simulate the trend of
the dataset and extract properties like the skew of the data and parameters
such as the measurement of center (mean, median, and mode) and
measurement of spread (variance and standard deviation). All these are
on one-dimensional data, and if the data is in multidimensional space
they use the covariance to see how each pair of variables goes together.
They detect the correlation between each pair to detect the relationship
and the association between the variable pairs. Also, they use what's called
hypothesis testing to infer the result of a hypothesis performed on sample
data from a dataset.
As we use deep learning to predict the future outcome based on a
given observation, we use a huge combination of linear algebra and
statistics as a black box to build and optimize the model.
We can’t say that deep learning consists 100% of statistics. A main
point to address is that deep learning is not just statistics—the same-old
stuff, just with bigger computers and a fancier name. This notion comes
from statistical concepts and terms that are prevalent in machine/deep
learning, such as regression, weights, biases, models, etc. Additionally,
many models approximate what can generally be considered statistical
functions: the softmax output of a classification model consists of logits,
making the process of training an image classifier a logistic regression. Also,
the least square algorithm is a statistical approach to optimize the fitted
line on linear regression.
Though the preceding paragraph is technically correct, reducing deep
learning as a whole to nothing more than a subsidiary of statistics is quite
wrong, and to think that deep learning just consists of statistics is a huge
7
Discovering Diverse Content Through
Random Scribd Documents
— Kiitos, herra Shaw, sanoi Polly ja nyökkäsi Tomille, joka sähkötti
takaisin 'mainiota' ja kävi päivällisen kimppuun kuin nuori susi.
— Ole huoleti, en minä nyt kaappaise. Halusin vain sanoa, että jos
lähdet huomennakin ulos, niin mennään laskemaan taas kunnolla
mäkeä.
PIKKU SEIKKOJA
— Sataa niin hijveästi, etten voi mennä ulos, ja kaikki ovat äkäisiä
minulle eivätkä tahdo leikkiä minun kanssani, sanoi Maud, kun Polly
tapasi hänet portailta murjottamassa ja pysähtyi kysymään, miksi
hän oli niin huonolla tuulella.
— Entä jos ratkoisit vaatteet sen päältä; minä näytän sitten miten
uusia tehdään. Sen jälkeen voit pukea ja riisua Klaaran niin usein
kuin haluat.
Herra Shaw oli erittäin ystävällinen Pollylle, sillä hän piti tämän
vaatimattomasta ja kohteliaasta käytöksestä. Polly oli niin kiitollinen
hänen suopeudestaan, että unohti pian pelkonsa ja osoitti
mieltymystään pienillä palveluksilla, jotka suuresti ilahduttivat herra
Shaw'ta. Kun hän lähti aamuisin virastoonsa, Polly saattoi häntä
puiston halki vilkkaasti jutellen ja hyvästeli hänet hymysuin ja
päätään nyökyttäen, kun he erosivat suuren portin luona. Aluksi
herra Shaw ei paljon huomannutkaan näitä saattomatkoja, mutta
oppi pian kaipaamaan Pollya, ellei tämä tullut, sillä koko hänen
päivänsä kirkastui aina kun pieni harmaapukuinen olento, jolla oli
älykkäät kasvot ja iloinen ääni, tuli saattamaan häntä talvisen
puiston läpi käsi luottavaisesti hänen kädessään. Tullessaan
myöhään kotiin hän oli iloinen nähdessään ruskean kiharapään
odottavan ikkunassa, huomatessaan tohvelinsa ja sanomalehden
paikoillaan ja ahkeran jalkaparin valmiina palveluksiin.
— Mikä hätänä? Onko läksy liian vaikea? hän kysyi eräänä iltana,
kun kuuli ähkymistä pöydän toiselta puolen, missä Tom istua jurotti
resuinen kirjapinkka edessään, kädet tukkaan hautautuneina aivan
kuin pää olisi haljeta hirvittävistä ponnistuksista.
— Minä olen lukenut koko kirjan läpi, et sinä saa minua kiinni.
— Luin Jimmyn kanssa, sillä isä antoi meidän lukea yhdessä kaikki
läksyt. Se oli hauskaa ja me opimme nopeasti!
— Enpä luule, enkä sitä paitsi välitä vaivata häntä, vaikka hän
tietäisikin.
— Miksi et?
— Miten hän voisi, kun olet aina piikit pystyssä? kysyi Polly hetken
mietittyään ja keksimättä parempaa vastausta.
— Miksei hän sitten anna minulle polkupyörää? Hän lupasi sen, jos
teen kunnollisesti koulutehtävät kuukauden ajan; ja olen nyt rehkinyt
kuin viimeistä päivää vähintään kuusi viikkoa eikä hän ole
tietääkseenkään. Tytöt saavat kyllä kerjätyksi hepenensä. Minä en
viitsi kerjätä, mutta älä luulekaan, että rupean lukemaan itseäni
kuoliaaksi turhan takia.
— Voi, Tom! Esititkö sinä sen? Sehän oli hienoa! Jim ja minä
lausuimme usein Horatiusta yhdessä, ja se oli kauhean hauskaa.
Näytä nyt miten sinä esitit runon. Minä pidän siitä kovasti.
— Eikö ollutkin loistavaa? Eikö Tom lausunut hyvin? Kai hän nyt
saa sen polkupyörän?
Polly oli ollut oikeassa, ja Tom myönsi mielessään, että 'isäukko' oli
kiltti ja piti hänestä eikä ollut unohtanut lupaustaan. Isän
odottamaton kiittely sai Tomin punastumaan mielihyvästä ja
näpelöimään takinnappeja, mutta sitten hän katsoi iloisena tätä
suoraan silmiin ja vastasi yhteen hengenvetoon:
— Opettelen varmasti.
Tomin oli maattava sisällä koko viikko, ja hän oli varsin jännittävän
näköinen iso musta laastarilappu otsassaan. Kaikki hemmottelivat
häntä, sillä tohtori oli sanonut, että jos isku olisi sattunut
tuumankaan lähemmäksi ohimoa, kuolema olisi ollut seurauksena.
Niinpä entinen nyrpeä Tom tuntui kaikista entistä rakkaammalta
heidän ajatellessaan, että olisivat voineet äkkiä menettää hänet. Isä
kyseli hänen vointiaan monta kertaa päivässä, äiti puheli
lakkaamatta "rakkaasta pojasta, joka töin tuskin oli pelastunut
onnettomuudesta", isoäiti syötti hänelle kaiken maailman herkut ja
tytöt palvelivat häntä kuin nöyrät orjattaret.
— Riitelittekö te koskaan?
— Olet sinäkin jos vain haluat. Eikö sinustakin, Fanny, Tom ole
ollut kiltti ja kärsivällinen ja eikö meistä kaikista ole hauskaa, että
hän on niin taitava? sanoi Polly, jonka sydämeen vieläkin koski veljen
muisteleminen.
— On tosiaan. Hän on viime aikoina ollut kuin toinen poika; mutta
kyllä hän taas parannuttuaan muuttuu entiselleen, vastasi Fanny,
joka ei juuri luottanut sairasvuoteella tehtyyn kääntymykseen.
— Ja minä toivoisin että minulla olisi sellainen veli kuin Jim oli,
tiuskaisi Fanny, sillä hän tunsi moitetta Tomin sanoissa ja tiesi
ansaitsevansa sen.
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.
textbookfull.com