Deep Learning Patterns and Practices 1st Edition Andrew Ferlitsch 2024 scribd download
Deep Learning Patterns and Practices 1st Edition Andrew Ferlitsch 2024 scribd download
Deep Learning Patterns and Practices 1st Edition Andrew Ferlitsch 2024 scribd download
com
https://ebookmeta.com/product/deep-learning-patterns-and-
practices-1st-edition-andrew-ferlitsch/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/grokking-deep-learning-meap-
version-7-andrew-w-trask/
ebookmeta.com
https://ebookmeta.com/product/fluent-c-principles-practices-and-
patterns-1st-edition-christopher-preschern/
ebookmeta.com
https://ebookmeta.com/product/third-person-singular-a-mars-bahr-
mystery-mars-bahr-mysteries-book-1-k-j-erickson/
ebookmeta.com
Quarkus in Action (MEAP V03) Martin Štefanko
https://ebookmeta.com/product/quarkus-in-action-meap-v03-martin-
stefanko/
ebookmeta.com
https://ebookmeta.com/product/a-bluestocking-for-a-baron-a-duke-s-
daughters-the-elbury-bouquet-3-1st-edition-arietta-richmond/
ebookmeta.com
https://ebookmeta.com/product/frontier-midwife-amanda-kate-bridges/
ebookmeta.com
https://ebookmeta.com/product/calculus-on-heisenberg-manifolds-
am-119-1st-edition-richard-beals/
ebookmeta.com
Collective Bargaining Among Photo Engravers in
Philadelphia Ordinary Methods Applied to an Occupation
Which Is Both an Art and a Manual Trade Charles Leese
https://ebookmeta.com/product/collective-bargaining-among-photo-
engravers-in-philadelphia-ordinary-methods-applied-to-an-occupation-
which-is-both-an-art-and-a-manual-trade-charles-leese/
ebookmeta.com
Andrew Ferlitsch
MANNING
Deep Learning Patterns and Practices
Deep Learning
Patterns and Practices
ANDREW FERLITSCH
MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: [email protected]
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15 percent recycled and processed without the use of elemental
chlorine.
The author and publisher have made every effort to ensure that the information in this book
was correct at press time. The author and publisher do not assume and hereby disclaim any
liability to any party for any loss, damage, or disruption caused by errors or omissions, whether
such errors or omissions result from negligence, accident, or any other cause, or from an usage
of the information herein.
ISBN 9781617298264
Printed in the United States of America
brief contents
PART 1 DEEP LEARNING FUNDAMENTALS ..........................................1
1 ■ Designing modern machine learning 3
2 ■ Deep neural networks 19
3 ■ Convolutional and residual neural networks 43
4 ■ Training fundamentals 70
v
contents
preface xiii
acknowledgments xiv
about this book xv
about the author xx
about the cover illustration xxii
vii
viii CONTENTS
Pooling 48 Flattening 49
■
4 Training fundamentals
4.1 Forward feeding and backward propagation
70
71
Feeding 71 ■
Backward propagation 72
4.2 Dataset splitting 74
Training and test sets 74 ■
One-hot encoding 75
4.3 Data normalization 78
Normalization 78 ■
Standardization 80
4.4 Validation and overfitting 80
Validation 80 ■
Loss monitoring 84 ■
Going deeper with
layers 84
4.5 Convergence 86
4.6 Checkpointing and early stopping 88
Checkpointing 88 ■
Early stopping 90
4.7 Hyperparameters 91
CONTENTS ix
Epochs 91 ■
Steps 92 ■
Batch size 94 ■
Learning rate 95
4.8 Invariance 97
Translational invariance 98 Scale invariance 104 ■
Classifier 160
6.2 Inception v2: Factoring convolutions 161
6.3 Inception v3: Architecture redesign 163
Inception groups and blocks 165 Normal convolution ■
168
Spatial separable convolution 169 Stem redesign and ■
network 185
Dense group 185 Dense block 188 DenseNet macro-
■ ■
9 Autoencoders
9.1
250
Deep neural network autoencoders 251
Autoencoder architecture 251 ■
Encoder 252 ■
Decoder 253
Training 254
CONTENTS xi
10 Hyperparameter tuning
10.1 Weight initialization
275
277
Weight distributions 277 ■
Lottery hypothesis 278 ■
Warm-up
(numerical stability) 280
10.2 Hyperparameter search fundamentals 283
Manual method for hyperparameter search 284 Grid ■
11 Transfer learning
11.1
302
TF.Keras prebuilt models 304
Base model 305 Pretrained ImageNet models for
■
12 Data distributions
12.1 Distribution types
325
326
Population distribution 327 Sampling distribution ■
328
Subpopulation distribution 329
12.2 Out of distribution 330
The MNIST curated dataset 330 Setting up the ■
13 Data pipeline
13.1
346
Data formats and storage 348
Compressed and raw-image formats 348 ■
HDF5 format 352
DICOM format 356 TFRecord format ■
358
13.2 Data feeding 364
NumPy 364 ■
TFRecord 366
13.3 Data preprocessing 368
Preprocessing with a pre-stem 368 ■
Preprocessing with TF
Extended 376
13.4 Data augmentation 381
Invariance 381 ■
Augmentation with tf.data 383 ■
Pre-stem 384
index 435
preface
As a Googler, one of my duties is to educate software engineers on how to use machine
learning. I already had experience creating online tutorials, meetups, conference pre-
sentations, training workshops, and coursework for private coding schools and univer-
sity graduate studies, but I am always looking for new ways to effectively teach.
Prior to Google, I worked in Japanese IT as a principal research scientist for 20
years—all without deep learning. Almost everything I see today, we were doing in
innovation labs 15 years ago; the difference is we needed a room full of scientists and
a vast budget. It’s incredible how things have so rapidly changed as a result of deep
learning.
Back in the late 2000s, I was working with small structured datasets with geospatial
data from national and international sources all over the world. Coworkers called me
a data scientist, but nobody knew what a data scientist really was. Then came big data,
and I didn’t know the big data tools and frameworks, and suddenly I wasn’t a data sci-
entist. What? I had to scramble and learn the tools and concepts behind big data and
once again I was a data scientist.
Then emerged machine learning on big datasets, like linear/logistic regression
and CART analysis, and I hadn’t used statistics since graduate school decades ago, and
once again I was not a data scientist. What? I had to scramble to learn statistics all over
again, and once again I was a data scientist. Then came deep learning, and I didn’t
know the theory and frameworks for neural networks and suddenly I wasn’t a data sci-
entist. What? I scrambled again and learned deep learning theory and other deep
learning frameworks. And once again, I am a data scientist.
xiii
acknowledgments
I would like to thank all those at Manning who helped throughout this process. Fran-
ces Lefkowitz, my development editor; Deirdre Hiam, my project editor; Sharon
Wilkey, my copyeditor; Keri Hales, my proofreader; and Aleksandar Dragosavljević,
my reviewing editor.
To all the reviewers: Ariel Gamino, Arne Peter Raulf, Barry Siegel, Brian R. Gaines,
Christopher Marshall, Curtis Bates, Eros Pedrini, Hilde Van Gysel, Ishan Khurana, Jen
Lee, Karthikeyarajan Rajendran, Michael Kareev, Muhammad Sohaib Arif, Nick
Vazquez, Ninoslav Cerkez, Oliver Korten, Piyush Mehta, Richard Tobias, Romit Sing-
hai, Sayak Paul, Sergio Govoni, Simone Sguazza, Udendran Mudaliyar, Vishwesh Ravi
Shrimali, and Viton Vitanis, your suggestions helped make this a better book.
To all Google Cloud AI staff who have shared their personal and customer insights,
your insights helped the book cover a broader audience.
xiv
Other documents randomly have
different content
presence in the Synagogue is of comparatively modern date. The
ner tamid of the Sanctuary, however, is explained to be a lamp
burning “from evening to morning” (Exod. xxvii. 21). A golden
candlestick standing in the Sanctuary against the south side, with its
seven branches arranged from east to west, served this purpose.
According to Tradition it was the second branch, counting from east
to west, which really burnt continually; but this was not considered as
implied in the term ner tamid, which only meant “a continual lamp” in
the sense of a lamp that burns regularly every night.
The ner tamid in the Synagogue, which burns continually day and
night, is not mentioned by any of the earlier Rabbinical authors. It
has been introduced as a symbol representing our conviction that
from the Synagogue shall continually come forth the light of
instruction, the light of comfort and blessing, and the light of love and
peace.
In the Synagogue women are separated from men. There was also
in the Temple an עזרת נשים“court of the women,” distinguished from
the עזרת אנשים“court of the men,” to which women had no access.
During the Feast of Tabernacles, when the great rejoicings in the
Temple attracted a large assembly, special care was taken (תקון גדול
היה שם) that the separation of the sexes should be maintained
(Mishnah, Succah v. 2; and [427]Talm. B., Succah 51b). This
precedent has been followed in the Synagogue, and has been
accepted as law up to this day.
Reservedness and modesty (צניעות) have always been the pride and
ornament of Jewish women, both in their homes and in the
Synagogue; hence also their taking a silent part in the public
devotion is an honour to them, and by no means derogatory.
The Ritual.
The reading of shema in the evening and in the morning, the three
sections constituting the shema, and the order of these sections, are
assumed in the Mishnah as fully established by law and usage. Only
a few regulations are discussed concerning the time and the mode of
the reading. There was this difference between the custom of the
Babylonian Jews and that of their brethren in Palestine, that the
latter omitted in the evening the passage referring to tsitsith. Later
on, however, the Palestine Jews conformed to the Babylonian
custom. Suggestions have been made [432]to substitute other Biblical
passages for shema, but they have been rejected. Several attempts
have been made to introduce, as an addition to the three sections of
shema, the reading of the Decalogue; the addition was disallowed,
lest people should be misled to think that the Ten Commandments
alone were to be observed, and that the other laws were not binding
(Babyl. T., Berachoth 12a). 122
The ritual which was adopted for the priests in the Temple was an
abridged form of the ritual then in general use. It was as follows:
They commenced with a benediction—the first of those which
precede the shema (יוצר אור); then they read the Decalogue, shema
(the three paragraphs), and three further benedictions, אמת ויציב,
עבודה(corresponding to רצהin our prayer), and the blessing of the
priests (Mishnah, Tamid v. 1).
At the conclusion of the Talmud (about 500 c.e.) the essential parts
of our present ritual were already in a settled state; the shema with
the benedictions preceding and following, the tefillah with its
variations for New-moon, Sabbath, and Holy-days, the reading from
the Law and the prophets, and Hallel. The Seder evening Service
was complete in its main parts. [434]Of the Benedictions (Berachoth)
on various occasions both form and contents were fixed, and the rule
was laid down by Rabbi Meir (Berachoth 40a) that he who uttered a
berachah in a form different from that fixed by our Sages has not
fulfilled his duty (or, according to Maimonides, Hilchoth Berachoth i.
5, is in error). Notwithstanding this rule, however, changes were
made; new benedictions were introduced and old ones
discontinued. 124—Kaddish and Kedushah seem to have formed part
of the Service; of the latter the Talmud mentions the name, of the
former the response: “May his great Name be praised” יהא שמו הגדול
מבורךor יהא שמיה רבא מ׳(Comp. Babyl. Talm., Berachoth 3a).
In the next period, that of the Geonim, we meet with the complete
Siddur, “Arrangement” or “Order” of Service for ordinary days, for
Sabbaths and Festivals, Benedictions for all occasions, and Piyyutim
as optional additions. Such a Siddur was arranged by the Gaon
Rabbenu Saadiah (892–942), and another by the Gaon Rabbenu
Amram (about 880). Henceforth the principal prayers underwent only
insignificant alterations. Of the next period the most important
Siddurim are those included in the Mishneh-torah, at the end of the
second book, and that contained in the Machzor Vitry. 125
The two most essential elements in these Services are: (1) the
Reading of Shema (קריאת שמע), in the Maaribh and the Shacharith;
(2) the Tefillah or Amidah, common to all the Services.
The reading of the shema is preceded by two berachoth: (1) יוצר אור
Praise of the Creator for the regular sequence of day and night, light
and darkness; (2) אהבה רבהor אהבת עולםPraise of His goodness in
giving us the Torah, and prayer for His assistance in the study of the
Torah. The shema is followed by a berachah on the Redemption of
Israel; it contains a reflection on the last words of shema, “I am the
Lord your God,” an expression of our faith in the truth of these
words, which strengthen our belief in the future Redemption of
Israel. 128 In the Evening Service a second berachah follows,
beginning השכיבנו, and containing a prayer for protection during the
night. 129
The next thirteen paragraphs are petitions for our individual and
national well-being. For our individual well-being (4–9), namely, for
reason and wisdom (4), assistance in our endeavour to return to God
(5), forgiveness of our sins (6), deliverance from trouble (7), from
illness (8), and from want (9).—For our national well-being (10–15),
namely, for the gathering of those who are scattered (10), under
good leaders (11), protected from the evil designs of our foes (12),
for the support of the faithful (13), the rebuilding of Jerusalem (14),
and the advent of Messiah (15). The sixteenth paragraph is a prayer
that our petition may be accepted.—The last three paragraphs
include a petition for the re-establishment of Divine Service in the
Temple of Jerusalem (17), thanksgiving (18), and prayer for peace
and prosperity (19). When the prayer is finished we express the wish
that our lips, from which prayer to God has come forth, may not be
defiled by unworthy language.
There are two shorter forms of the tefillah for urgent occasions: the
one is a substitute for the “Eighteen,” in which the middle thirteen
paragraphs are contracted into one; it is called הביננו(the first word
of this middle section), or מעין שמונה עשרה“abstract of the
‘Eighteen.’ ” The other is a contraction of the Friday evening tefillah,
and is called מעין שבע“abstract of the ‘Seven’ ” (scil., paragraphs
forming the tefillah), originally intended for those who were too late
for the full Service. 130
Each of the above Services ends with a prayer called after its initial
word alenu, “It is our duty.” In this prayer we thank God that we have
the privilege of proclaiming His Unity, and express our hope to see
the worship of the One God adopted by all mankind. It is omitted
between two Services following closely the one upon the other.
The following points mark off the Public Service from the various
forms of private prayer:—
(3.) קריאת התורה“the Reading of the Law,” and the “Lessons from the
Prophets” (הפטרה), with the benedictions preceding and following
(supra, p. 348).
There are various short forms of this ברכת המזון; the shortest is that
for children, “Blessed be the Merciful, the Giver of this bread.” 134—
When three grown-up male persons or more have their meal
together, [444]a special introductory form is used, called זמון
“summons to prayer,” one of the company acting as Reader, and the
rest forming the congregation.
Notes.
We bend the knee, incline our head, and bow down on certain
occasions during the Service, but we do not kneel during prayer.—It
has perhaps been avoided as an idolatrous practice, with reference
to Judges vii. 5.
When the Ark is opened and the Sefer is taken out or put back, we
stand and show our respect for the Word of God in various ways.
Some bow the head; others, considering this as worship, kiss the
Sefer, or otherwise express their reverence.
2. On Page 439.
There are various parts in our Service which originally seem to have
formed a substitute, under certain circumstances, for a section of the
Service or for the whole of it, but were subsequently, when the
circumstances altered, embodied as an integral part of the Service in
addition to the sections which they had replaced.
In the Maaribh the part beginning ברוך יי לעולםand ending על כל מעשיו
was originally a substitute for the Amidah, and the conclusion of the
Evening Service for those who considered the tefillah in the evening
optional. Similarly, on Friday evening the contracted tefillah was
originally a substitute for the tefillah for those who came late. In both
these and similar cases the substitute and its original have been
retained as integral parts of the Service.
In the public Service the tefillah is repeated by the Reader after the
silent prayer (בלתש) of the congregation. This minhag must have
been introduced very early. In the Talmud (end of Rosh ha-shanah) it
is spoken of as a regular institution, its purpose is discussed, and the
reason stated why we should not dispense with the Reader’s
repetition or with the silent tefillah. It seems that there was, on the
one hand, a desire on the part of the congregants to have an
uninterrupted silent tefillah in which they could give suitable
expression each one to his personal and peculiar wants and wishes.
On the other hand, there was also a desire felt by many to be guided
in their devotions by the Reader. Our minhag satisfies both
requirements. But it is a grave error to think, as unfortunately many
do, that, while the Reader repeats the tefillah, the congregants may
turn their heart and mind to other things, however holy these be. The
congregation and the Reader must be united in devotion during תפלה
בצבור, and where the continued concentration of thought during the
tefillah and its repetition seems unattainable, it would be better to
sacrifice the minhag of repeating the tefillah rather than to have the
repetition of the prayer without the participation of the congregants,
or even without decorum.
In the first kedushah (called קדושה דיוצר), while praising God [448]as
the Creator of light and of the heavenly luminaries, we introduce
these, as proclaiming, as it were, the holiness and glory of God in
the words of the Prophets. In the last kedushah (called קדושה דסידרא
or סידרא דקדושה) we merely read, among other passages from the
Prophets, those verses of Isaiah and Ezekiel which contain the chief
sentences of the kedushah. In the kedushah of the tefillah the
Reader summons the congregation to proclaim the sanctification of
God in the manner of the angels above; it has therefore its place
only in Public Worship, whilst as to the other two kedushoth there is
no difference whether a person prays by himself or in a congregation
of worshippers.