Full Download Deep Learning Patterns and Practices 1st Edition Andrew Ferlitsch PDF DOCX
Full Download Deep Learning Patterns and Practices 1st Edition Andrew Ferlitsch PDF DOCX
com
https://ebookmeta.com/product/deep-learning-patterns-and-
practices-1st-edition-andrew-ferlitsch/
OR CLICK HERE
DOWLOAD 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: orders@manning.com
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
Discovering Diverse Content Through
Random Scribd Documents
6. Mrs. Greene’s will makes the five children equal beneficiaries.
In event of death of any of them the survivors share alike; and if all
should die the estate goes to their families, if any.
7. The sleeping-rooms of the Greenes are arranged thus: Julia’s
and Rex’s face each other at the front of the house; Chester’s and
Ada’s face each other in the centre of the house; and Sibella’s and
Mrs. Greene’s face each other at the rear. No two rooms
intercommunicate, with the exception of Ada’s and Mrs. Greene’s;
and these two rooms also give on the same balcony.
8. The library of Tobias Greene, which Mrs. Greene believes she
had kept locked for twelve years, contains a remarkably complete
collection of books on criminology and allied subjects.
9. Tobias Greene’s past was somewhat mysterious, and there
were many rumors concerning shady transactions carried on by him
in foreign lands.
First Crime
10. Julia is killed by a contact shot, fired from the front, at 11.30 P.
M.
11. Ada is shot from behind, also by a contact shot. She
recovers.
12. Julia is found in bed, with a look of horror and amazement on
her face.
13. Ada is found on the floor before the dressing-table.
14. The lights have been turned on in both rooms.
15. Over three minutes elapse between the two shots.
16. Von Blon, summoned immediately, arrives within half an hour.
17. A set of footprints, other than Von Blon’s, leaving and
approaching the house, is found; but the character of the snow
renders them indecipherable.
18. The tracks have been made during the half-hour preceding
the crime.
19. Both shootings are done with a .32 revolver.
20. Chester reports that an old .32 revolver of his is missing.
21. Chester is not satisfied with the police theory of a burglar, and
insists that the District Attorney’s office investigate the case.
22. Mrs. Greene is aroused by the shot fired in Ada’s room, and
hears Ada fall. But she hears no footsteps or sound of a door
closing.
23. Sproot is half-way down the servants’ stairs when the second
shot is fired, yet he encounters no one in the hall. Nor does he hear
any noise.
24. Rex, in the room next to Ada’s, says he heard no shot.
25. Rex intimates that Chester knows more about the tragedy
than he admits.
26. There is some secret between Chester and Sibella.
27. Sibella, like Chester, repudiates the burglar theory, but
refuses to suggest an alternative, and says frankly that any member
of the Greene family may be guilty.
28. Ada says she was awakened by a menacing presence in her
room, which was in darkness; that she attempted to run from the
intruder, but was pursued by shuffling footsteps.
29. Ada says a hand touched her when she first arose from bed,
but refuses to make any attempt to identify the hand.
30. Sibella challenges Ada to say that it was she (Sibella) who
was in the room, and then deliberately accuses Ada of having shot
Julia. She also accuses Ada of having stolen the revolver from
Chester’s room.
31. Von Blon, by his attitude and manner, reveals a curious
intimacy between Sibella and himself.
32. Ada is frankly fond of Von Blon.
Second Crime
33. Four days after Julia and Ada are shot, at 11.30 p. m., Chester
is murdered by a contact shot fired from a .32 revolver.
34. There is a look of amazement and horror on his face.
35. Sibella hears the shot and summons Sproot.
36. Sibella says she listened at her door immediately after the
shot was fired, but heard no other sound.
37. The lights are on in Chester’s room. He was apparently
reading when the murderer entered.
38. A clear double set of footprints is found on the front walk. The
tracks have been made within a half-hour of the crime.
39. A pair of galoshes, exactly corresponding to the footprints, is
found in Chester’s clothes-closet.
40. Ada had a premonition of Chester’s death, and, when
informed of it, guesses he has been shot in the same manner as
Julia. But she is greatly relieved when shown the footprint patterns
indicating that the murderer is an outsider.
41. Rex says he heard a noise in the hall and the sound of a door
closing twenty minutes before the shot was fired.
42. Ada, when told of Rex’s story, recalls also having heard a
door close at some time after eleven.
43. It is obvious that Ada knows or suspects something.
44. The cook becomes emotional at the thought of any one
wanting to harm Ada, but says she can understand a person having
a reason to shoot Julia and Chester.
45. Rex, when interviewed, shows clearly that he thinks some
one in the house is guilty.
46. Rex accuses Von Blon of being the murderer.
47. Mrs. Greene makes a request that the investigation be
dropped.
Third Crime
48. Rex is shot in the forehead with a .32 revolver, at 11.20 a. m.,
twenty days after Chester has been killed and within five minutes of
the time Ada phones him from the District Attorney’s office.
49. There is no look of horror or surprise on Rex’s face, as was
the case with Julia and Chester.
50. His body is found on the floor before the mantel.
51. A diagram which Ada asked him to bring with him to the
District Attorney’s office has disappeared.
52. No one up-stairs hears the shot, though the doors are open;
but Sproot, down-stairs in the butler’s pantry, hears it distinctly.
53. Von Blon is visiting Sibella that morning; but she says she
was in the bathroom bathing her dog at the time Rex was shot.
54. Footprints are found in Ada’s room coming from the balcony
door, which is ajar.
55. A single set of footprints is found leading from the front walk
to the balcony.
56. The tracks could have been made at any time after nine
o’clock that morning.
57. Sibella refuses to go away on a visit.
58. The galoshes that made all three sets of footprints are found
in the linen-closet, although they were not there when the house was
searched for the revolver.
59. The galoshes are returned to the linen-closet, but disappear
that night.
Fourth Crime
60. Two days after Rex’s death Ada and Mrs. Greene are
poisoned within twelve hours of each other—Ada with morphine,
Mrs. Greene with strychnine.
61. Ada is treated at once, and recovers.
62. Von Blon is seen leaving the house just before Ada swallows
the poison.
63. Ada is discovered by Sproot as a result of Sibella’s dog
catching his teeth in the bell-cord.
64. The morphine was taken in the bouillon which Ada habitually
drank in the mornings.
65. Ada states that no one visited her in her room after the nurse
had called her to come and drink the bouillon; but that she went to
Julia’s room to get a shawl, leaving the bouillon unguarded for
several moments.
66. Neither Ada nor the nurse remembers having seen Sibella’s
dog in the hall before the poisoned bouillon was taken.
67. Mrs. Greene is found dead of strychnine-poisoning the
morning after Ada swallowed the morphine.
68. The strychnine could have been administered only after 11 p.
m. the previous night.
69. The nurse was in her room on the third floor between 11 and
11.30 p. m.
70. Von Blon was calling on Sibella that night, but Sibella says he
left her at 10.45.
71. The strychnine was administered in a dose of citrocarbonate,
which, presumably, Mrs. Greene would not have taken without
assistance.
72. Sibella decides to visit a girl chum in Atlantic City, and leaves
New York on the afternoon train.
Distributable Facts
73. The same revolver is used on Julia, Ada, Chester, and Rex.
74. All three sets of footprints have obviously been made by
some one in the house for the purpose of casting suspicion on an
outsider.
75. The murderer is some one whom both Julia and Chester
would receive in their rooms, in negligé, late at night.
76. The murderer does not make himself known to Ada, but
enters her room surreptitiously.
77. Nearly three weeks after Chester’s death Ada comes to the
District Attorney’s office, stating she has important news to impart.
78. Ada says that Rex has confessed to her that he heard the
shot in her room and also heard other things, but was afraid to admit
them; and she asks that Rex be questioned.
79. Ada tells of having found a cryptic diagram, marked with
symbols, in the lower hall near the library door.
80. On the day of Rex’s murder Von Blon reports that his
medicine-case has been rifled of three grains of strychnine and six
grains of morphine—presumably at the Greene mansion.
81. The library reveals the fact that some one has been in the
habit of going there and reading by candle-light. The books that
show signs of having been read are: a handbook of the criminal
sciences, two works on toxicology, and two treatises on hysterical
paralysis and sleep-walking.
82. The visitor to the library is some one who understands
German well, for three of the books that have been read are in
German.
83. The galoshes that disappeared from the linen-closet on the
night of Rex’s murder are found in the library.
84. Some one listens at the door while the library is being
inspected.
85. Ada reports that she saw Mrs. Greene walking in the lower
hall the night before.
86. Von Blon asserts that Mrs. Greene’s paralysis is of a nature
that makes movement a physical impossibility.
87. Arrangements are made with Von Blon to have Doctor
Oppenheimer examine Mrs. Greene.
88. Von Blon informs Mrs. Greene of the proposed examination,
which he has scheduled for the following day.
89. Mrs. Greene is poisoned before Doctor Oppenheimer’s
examination can be made.
90. The post mortem reveals conclusively that Mrs. Greene’s leg
muscles were so atrophied that she could not have walked.
91. Ada, when told of the autopsy, insists that she saw her
mother’s shawl about the figure in the hall, and, on being pressed,
admits that Sibella sometimes wore it.
92. During the questioning of Ada regarding the shawl Mrs.
Mannheim suggests that it was she herself whom Ada saw in the
hall.
93. When Julia and Ada were shot there were, or could have
been, present in the house: Chester, Sibella, Rex, Mrs. Greene, Von
Blon, Barton, Hemming, Sproot, and Mrs. Mannheim.
94. When Chester was shot there were, or could have been,
present in the house: Sibella, Rex, Mrs. Greene, Ada, Von Blon,
Barton, Hemming, Sproot, and Mrs. Mannheim.
95. When Rex was shot there were, or could have been, present
in the house: Sibella, Mrs. Greene, Von Blon, Hemming, Sproot, and
Mrs. Mannheim.
96. When Ada was poisoned there were, or could have been,
present in the house: Sibella, Mrs. Greene, Von Blon, Hemming,
Sproot, and Mrs. Mannheim.
97. When Mrs. Greene was poisoned there were, or could have
been, present in the house: Sibella, Von Blon, Ada, Hemming,
Sproot, and Mrs. Mannheim.
When Markham had finished reading the summary, he went
through it a second time. Then he laid it on the table.
“Yes, Vance,” he said, “you’ve covered the main points pretty
thoroughly. But I can’t see any coherence in them. In fact, they seem
only to emphasize the confusion of the case.”
“And yet, Markham, I’m convinced that they only need
rearrangement and interpretation to be perfectly clear. Properly
analyzed, they’ll tell us everything we want to know.”
Markham glanced again through the pages.
“If it wasn’t for certain items, we could make out a case against
several people. But no matter what person in the list we may assume
to be guilty, we are at once confronted by a group of contradictory
and insurmountable facts. This précis could be used effectively to
prove that every one concerned is innocent.”
“Superficially it appears that way,” agreed Vance. “But we first
must find the generating line of the design, and then relate the
subsidi’ry forms of the pattern to it.”
Markham made a hopeless gesture.
“If only life were as simple as your æsthetic theories!”
“It’s dashed simpler,” Vance asserted. “The mere mechanism of a
camera can record life; but only a highly developed creative
intelligence, with a profound philosophic insight, can produce a work
of art.”
“Can you make any sense—æsthetic or otherwise—out of this?”
Markham petulantly tapped the sheets of paper.
“I can see certain traceries, so to speak—certain suggestions of a
pattern; but I’ll admit the main design has thus far eluded me. The
fact is, Markham, I have a feeling that some important factor in this
case—some balancing line of the pattern, perhaps—is still hidden
from us. I don’t say that my résumé is insusceptible of interpretation
in its present state; but our task would be greatly simplified if we
were in possession of the missing integer.”
Fifteen minutes later, when we had returned to Markham’s main
office, Swacker came in and laid a letter on the desk.
“There’s a funny one, Chief,” he said.
Markham took up the letter and read it with a deepening frown.
When he had finished, he handed it to Vance. The letter-head read,
“Rectory, Third Presbyterian Church, Stamford, Connecticut”; the
date was the preceding day; and the signature was that of the
Reverend Anthony Seymour. The contents of the letter, written in a
small, precise hand, were as follows:
98. Sibella and Von Blon were secretly married a year ago.