Pro Deep Learning With Tensorflow 2.0: A Mathematical Approach To Advanced Artificial Intelligence in Python 2Nd Edition Santanu Pattanayak
Pro Deep Learning With Tensorflow 2.0: A Mathematical Approach To Advanced Artificial Intelligence in Python 2Nd Edition Santanu Pattanayak
com
https://ebookmeta.com/product/applied-deep-learning-with-
tensorflow-2-learn-to-implement-advanced-deep-learning-
techniques-with-python-2nd-edition-umberto-michelucci-2/
https://ebookmeta.com/product/applied-deep-learning-with-
tensorflow-2-learn-to-implement-advanced-deep-learning-
techniques-with-python-2nd-edition-umberto-michelucci/
https://ebookmeta.com/product/learn-tensorflow-2-0-implement-
machine-learning-and-deep-learning-models-with-python-1st-
edition-pramod-singh/
https://ebookmeta.com/product/quantum-machine-learning-with-
python-using-cirq-from-google-research-and-ibm-qiskit-1st-
edition-santanu-pattanayak/
Deep Reinforcement Learning with Python: With PyTorch,
TensorFlow and OpenAI Gym 1st Edition Nimish Sanghi
https://ebookmeta.com/product/deep-reinforcement-learning-with-
python-with-pytorch-tensorflow-and-openai-gym-1st-edition-nimish-
sanghi-3/
https://ebookmeta.com/product/deep-reinforcement-learning-with-
python-with-pytorch-tensorflow-and-openai-gym-1st-edition-nimish-
sanghi/
https://ebookmeta.com/product/deep-reinforcement-learning-with-
python-with-pytorch-tensorflow-and-openai-gym-1st-edition-nimish-
sanghi-2/
https://ebookmeta.com/product/deep-learning-with-python-2nd-
edition-nikhil-ketkar/
https://ebookmeta.com/product/deep-learning-with-swift-for-
tensorflow-rahul-bhalley/
Pro Deep
Learning with
TensorFlow 2.0
A Mathematical Approach to Advanced
Artificial Intelligence in Python
—
Second Edition
—
Santanu Pattanayak
Pro Deep Learning with
TensorFlow 2.0
A Mathematical Approach to
Advanced Artificial Intelligence
in Python
Second Edition
Santanu Pattanayak
Pro Deep Learning with TensorFlow 2.0: A Mathematical Approach to Advanced
Artificial Intelligence in Python
Santanu Pattanayak
Prestige Ozone
Bangalore, Karnataka, India
Introduction�����������������������������������������������������������������������������������������������������������xvii
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
GPU������������������������������������������������������������������������������������������������������������������������������������������� 196
TPU�������������������������������������������������������������������������������������������������������������������������������������������� 196
Summary���������������������������������������������������������������������������������������������������������������������������������� 197
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 635
xii
About the Author
Santanu Pattanayak works as a Senior Staff Machine
Learning Specialist at Qualcomm Corp R&D and is the
author of Quantum Machine Learning with Python,
published by Apress. He has more than 16 years of
experience, having worked at GE, Capgemini, and IBM
before joining Qualcomm. He graduated with a degree in
electrical engineering from Jadavpur University, Kolkata, and
is an avid math enthusiast. Santanu has a master’s degree in
data science from the Indian Institute of Technology (IIT),
Hyderabad. Currently, he resides in Bangalore with his wife.
xiii
About the Technical Reviewer
Manohar Swamynathan is a data science practitioner and
an avid programmer, with over 14+ years of experience
in various data science–related areas that include data
warehousing, business intelligence (BI), analytical tool
development, ad hoc analysis, predictive modeling, data
science product development, consulting, formulating
strategies, and executing analytics programs. He’s had
a career covering the life cycle of data across different
domains, such as US mortgage banking, retail/ecommerce,
insurance, and industrial IoT. He has a bachelor’s degree
with a specialization in physics, mathematics, and
computers and a master’s degree in project management.
He’s currently living in Bengaluru, the Silicon Valley of India.
xv
Introduction
Pro Deep Learning with TensorFlow 2.0 is a practical and mathematical guide to deep
learning using TensorFlow. 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
toward 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, Pro Deep Learning with TensorFlow 2.0 provides practical, hands-on
expertise so you can learn deep learning from scratch and 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
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.
xvii
Another random document with
no related content on Scribd:
The broth of boiled meat should always be saved to use in soups,
stews, and gravies. Stewing and simmering meats means to place
them near enough to the fire to keep the water on them bubbling
moderately, constantly, and slowly. Salt meats should be put over
the fire in cold water, which as soon as it boils should be replaced by
fresh cold water, the water to be changed until it remains fresh
enough to give the meat a palatable flavor when done. Salted and
smoked meats require about 30 minutes’ very slow boiling, from the
time the water boils, to each pound. Vegetables and herbs may be
boiled with them to flavor them. When they are cooked the vessel
containing them should be set where they will keep hot without
boiling until required, if they are to be served hot; if they are to be
served cold, they should be allowed to cool in the pot liquor in which
they were boiled. Very salt meats, or those much dried in smoking,
should be soaked overnight in cold water before boiling.
Roasting
Wipe meat with damp cloth. Trim and tie into shape if necessary.
In the bottom of pan put some pieces of fat from meat. Arrange
meat on rack in pan. Dredge with salt, pepper, and flour. Have oven
very hot at first; when meat is half done reduce heat. Baste every 10
or 15 minutes. If there is danger of fat in pan being scorched add a
few spoons of boiling water. Allow from 10 to 20 minutes per pound
of meat, according as it is desired rare or well done. When done
remove to hot platter. Thicken gravy in pan with browned flour,
adding more water as necessary and add seasoning.
Yorkshire Pudding.-¾ pint flour, 3 eggs, 1½ pints milk, pinch
salt, 1½ teaspoons Royal Baking Powder. Sift flour and powder
together, add eggs, beaten with milk, stir quickly into rather thinner
batter than for griddle cakes, pour into dripping-pan, plentifully
greased with beef-dripping, bake in hot oven 25 minutes; serve with
roast beef.
Braised Beef.—Wipe and trim 6 pounds round or rump of beef
without bone. Sear brown on all sides in very hot frying-pan over hot
fire. In braising-pan or iron kettle put layers of sliced onions, turnips,
and carrots; add bunch of sweet herbs, 1 teaspoon salt, ½ teaspoon
pepper; on this lay meat. Add 1 pint boiling water (or water and
stewed tomatoes). Cover closely and cook 4 hours in moderate
oven. If water evaporates rapidly add more. Transfer meat to hot
platter. Strain, thicken, and season gravy. The vegetables may be
served separately if desired.
Braised Veal Shoulder.—Have shoulder boned. Fill with stuffing
(see Stuffings). Prepare bed of vegetables as for braised beef. Lay
veal on it, add 1 pint boiling water, 1 pint stewed tomatoes, ½
teaspoon salt, ¼ teaspoon pepper. Cover and cook 4 hours in
moderate oven. Uncover and brown. Serve strained gravy separately.
Broiled Steak.—Trim and wipe steak, which should be at least 1
inch thick. Rub broiler with fat, arrange steak with thickest part in
center of broiler. Have fire clear and very hot, but without blaze.
Hold steak close to fire. Turn every ½ minute, that it may sear
quickly. When ½ done season with salt and pepper. Steak 1 inch
thick will broil in 4 minutes.
Panned Steak or Chops.—Trim and wipe steak. Heat frying-pan
until it smokes all over. Rub bottom with a bit of fat. Lay in steak and
turn every 10 seconds. Keep pan very hot. Season when ½ done.
Mutton and pork chops, ham and bacon, may be panned in same
way.
If hot platter for steak is rubbed with a cut onion it will give a
delightful flavor to the meat.
Broiled Ham and Poached Eggs.—Cut slices of boiled ham of
equal size; broil on a gridiron over a clear fire; lay on a hot dish. Lay
on each a poached egg, neatly trimmed, and serve.
Beefsteak Pie (French style).—Take a nice piece of beef, rump
or sirloin, cut in small slices; slice also a little raw ham; put both in a
frying-pan, with some butter and small quantity chopped onions; let
them simmer together a short time on the fire or in the oven; add a
little flour and enough stock to make sauce; salt, pepper, chopped
parsley, and a little Worcestershire sauce as seasoning; add also a
few sliced potatoes, and cook together for about 20 minutes; put
this into a pie-dish, with a few slices of hard-boiled eggs on the top,
and cover with a layer of common paste. Bake from 15 to 20
minutes in a well-heated oven. All dark-meat pies can be treated
precisely in the same way. If poultry, leave the potatoes out.
To Boil a Ham.—A blade of mace, a few cloves, a sprig of thyme,
and 2 bay-leaves. Well soak ham in large quantity of water for 24
hours, then trim and scrape very clean; put into large stewpan, with
more than sufficient water to cover it; put in mace, cloves, thyme,
and bay-leaves. Boil 4 or 5 hours, according to weight; when done,
let it become cold in liquor in which it was boiled. Then remove rind
carefully, without injuring the fat; press cloth over it to absorb as
much of the grease as possible. It is always improved by setting in
the oven for nearly an hour, till much of the fat dries out, and it also
makes it more tender. Shake some bread raspings over the fat.
Serve cold garnished with parsley.
Boiled Mutton or Lamb.—Trim and wipe the meat. Have ready
kettle of rapidly boiling salted water. Immerse meat, boil hard 5
minutes, then reduce to gentle simmer. Allow 12 to 15 minutes per
pound. Lamb should always be well done; mutton may be rare. A
little rice may be added to water to keep meat white; if a few
vegetables are also added the pot liquor will make a good thick
soup.
Boiled Corned Beef and Turnips.—Select a piece not too salt.
The brisket is a good cut for family use when not too fat. Cook beef
in plenty cold water. Bring slowly to boil. Cook 18 minutes to the
pound after it begins to simmer. When fully ¾ done put in a dozen
turnips, peeled and quartered. When both beef and turnips are
thoroughly done dish out the beef, and lay the turnips, unmashed,
about it. Serve with drawn butter, having as a base the pot liquor.
Remaining liquor will make a good soup for next day’s dinner.
Pork Chops with Tomato Gravy.—Trim off skin and fat; rub the
chops over with a mixture of powdered sage and onion; put small
piece butter into a frying-pan; put in the chops and cook slowly, as
they should be well done. Lay chops on hot dish; add a little hot
water to gravy in pan, 1 large spoon butter rolled in flour, pepper,
salt, and sugar, and ½ cup juice drained from can tomatoes. The
tomatoes themselves can be used for a tomato omelet. Stew 5
minutes and pour over the chops and serve.
Sausages.—Have ¾ lean and ¼ fat pork chopped very fine, 1
pound salt, ¼ pound pepper, and tea-cup sage to every 40 pounds
meat. Warm the meat, that you can mix it well with your hands, do
up a part in small patties mixed with a little flour, the rest pack in
jars. When to be used, do it up in small cakes, flour the outside, fry
in butter or alone. They should not be covered while frying, or they
will fall to pieces. They should be kept where it is cool, but not
damp. To prevent sausages from bursting when cooking, never make
a hole in them with a fork while turning them.
Fried Salt Pork.—Cut fat salt pork in thin slices and soak in milk
for a few hours. Pour boiling water over, drain, and fry until crisp.
When partly fried they may be dipped into batter (see Fritters), then
finished in the same pan, turning several times.
Pork and Beans.—Soak 1 quart white beans overnight in cold
water. Drain, add fresh water, and simmer gently till tender. Put in
baking-pan and place in center, rind up, gashed, ½ pound fat salt
pork parboiled. Mix 1 teaspoon salt, ½ teaspoon dry mustard, and 1
tablespoon molasses; add to the beans, with enough boiling water
to cover. Bake 8 hours in a moderate oven, adding more water as
necessary.
Liver and Bacon.—Cut liver in ½-inch slices, soak in cold water
20 minutes, drain, dry, and roll in flour. Have pan very hot. Put in
bacon thinly sliced, turn until brown, transfer to hot platter. Fry liver
quickly in the hot fat, turning often. When done pour off all but 1 or
2 tablespoons fat, dredge in flour until it is absorbed, and stir till
brown. Add hot water gradually to make smooth gravy, season and
boil 1 minute. Serve separately.
Few people know that lamb’s liver is as tender and well flavored as
calf’s liver; it is much less expensive.
Stew, Irish.—Time, about 2 hours. 2½ pounds chops, 8
potatoes, 4 turnips, 4 small onions, nearly a quart of water. Take
some chops from loin of mutton, place them in a stewpan in
alternate layers of sliced potatoes and chops; add turnips and onions
cut into pieces, pour in nearly quart cold water; cover stewpan
closely, let stew gently till vegetables are ready to mash and greater
part of gravy is absorbed; then place in a dish; serve it up hot.
Brown Beef Stew.—Cut 2 pounds beef in small pieces. Melt
some of the fat in a pan, brown in it ½ the meat. Put rest of meat in
kettle with 1 pint cold water, let stand 20 minutes, then heat slowly.
Transfer browned meat to kettle; thicken fat with two tablespoons
browned flour, add 1 pint boiling water and stir; when thick strain
into kettle. Add 1 cup diced carrot, cover, and simmer. When half
done add 1 pint diced potatoes. Season well with salt and pepper.
Mutton Haricot.—Cut 2 pounds breast mutton in pieces, roll in
flour, and brown in drippings. Transfer to a stewpan, add 2 sliced
onions, cover with boiling water, and simmer until very tender. Add 1
pint parboiled potatoes or 1 pint boiled macaroni and 1 pint shelled
peas; season, simmer till vegetables are done.
Brown Kidney Stew.—From a beef kidney cut off the outside
meat in bits, rejecting tubes and purplish cores. Cover with cold
water; heat slowly till steaming, drain, add cold water, and heat a
second and again a third time. To the drained kidneys add 1 cup
brown sauce (see Sauces), season very highly with Worcestershire
and catsup, and stand over hot water for 10 minutes.
To Roast a Leg of Pork.—Choose a small leg of fine young pork;
cut a slit in the knuckle with a sharp knife, and fill the space with
sage, and onions chopped, and a little pepper and salt. When half
done score the skin in slices, but do not cut deeper than the outer
rind. Apple sauce and potatoes should be served to eat with it.
Sweetbreads.—Scald in salted water; remove stringy parts; put
in cold water 5 or 10 minutes; drain in towel; dip in egg and bread
or cracker crumbs, fry in butter, or broil them plain.
Veal Cutlets, Breaded.—Trim and flatten the cutlets, pepper and
salt, and roll in beaten egg, then in pounded cracker. Fry rather
slowly in good dripping, turning when the lower side is brown. Drain
off the fat, squeeze a little lemon juice upon each, and serve in a hot
flat dish.
Stuffings
USE glass bottles for pickles, also wooden knives and forks in
preparation of them. Fill bottles 3 parts full with articles to be
pickled, then fill bottle with vinegar. Use saucepans lined with
earthenware, or stone pipkins, to boil vinegar in.
Chow Chow.—1 quart large cucumbers, 1 quart small
cucumbers, 2 quarts onions, 4 heads cauliflower, 6 green peppers, 1
quart green tomatoes, 1 gallon vinegar, 1 pound mustard, 2 cups
sugar, 2 cups flour, 1 ounce turmeric. Put all in salt and water one
night; cook all the vegetables in brine until tender, except large
cucumbers. Pour over vinegar and spices.
Pickling Cauliflowers.—Take whitest and closest cauliflowers in
bunches; spread on earthen dish, cover them with salt, and let stand
3 days to draw out all the water. Then put in jars, pour boiling salt
and water over them, let stand overnight; then drain with a hair-
sieve, and put in glass jars; fill up jars with vinegar; cover tight.
Piccalilly.—1 peck green tomatoes, sliced; ½ peck onions, sliced;
1 cauliflower, 1 peck small cucumbers. Leave in salt and water 24
hours; then put in kettle with handful scraped horse-radish, 1 ounce
turmeric, 1 ounce cloves (whole), ¼ pound pepper (whole), 1 ounce
cassia-buds or cinnamon, 1 pound white mustard seed, 1 pound
English mustard. Place in kettle in layers, and cover with cold
vinegar. Boil 15 minutes, constantly stirring.
Pickled Red Cabbage.—Slice it into a colander, sprinkle each
layer with salt; let it drain 2 days, then put into a jar, pour boiling
vinegar enough to cover, put in a few slices of red beet-root. Choose
purple red cabbage. Those who like flavor of spice will boil it with
the vinegar. Cauliflower cut in bunches, and thrown in after being
salted, will look red and beautiful.
Tomato Catsup.—1 gallon tomatoes (strained), 6 tablespoons
salt, 3 tablespoons black pepper, 1 tablespoon cloves, 2 tablespoons
cinnamon, 2 tablespoons allspice, 1½ pints vinegar; boil down one
half. 1 peck tomatoes will make 1 gallon strained.
Walnut Catsup.—Take green walnuts before the shell is formed
(usually in a proper state early in August). Grind them or pound
them in an earthen or marble mortar. Squeeze out the juice through
a coarse cloth, and add to every gallon of juice 1 pound of
anchovies, 1 pound salt, 4 ounces cayenne pepper, 2 ounces black
pepper, 1 ounce each ginger, cloves, and mace, and the root of one
horse-radish. Boil all together till reduced to half the quantity. Pour
off, and when cold bottle tight. Use in 3 months.
Beverages
ALWAYS prepare food for the sick in the neatest and most careful
manner. In sickness the senses are unusually acute, and far more
susceptible to carelessness, negligence, and mistakes in the
preparation and serving of food than when in health.
Corn Meal Gruel.—Mix 1 tablespoon corn meal, ½ teaspoon salt,
and 2 tablespoons cold water. Add 1 pint boiling water, simmer
slowly 1 hour. In serving bowl put 2 tablespoons cream, 1 lump
sugar, strain in gruel, stir for a moment, and serve.
Flour and arrowroot gruel is made in the same way, but cooked
only 10 minutes.
Farina gruel is made with milk and cooked 1 hour in double boiler.
Boil oatmeal gruel 1 hour and strain.
Barley Water.—Wash 2 tablespoons pearl barley, scald with
boiling water, boil 5 minutes, strain. Add 2 quarts cold water, simmer
till reduced ½. Strain, add lemon juice to taste. Good in fevers.
Wine Whey.—Scald 1 cup milk, add 1 cup wine, cook gently till it
wheys. Strain through cheese-cloth.
Beef Tea.—Chop very fine 1 pound lean beef round. Cover with
½ pint cold water. Stand in cold place 1 hour. Set over hot water, stir
till liquid begins to turn color. Strain, add pinch salt. To reheat, set
cup in pan of hot water.
Restorative Jelly.—Put in glass jar ½ box granulated gelatine, 1
tablespoon granulated gum arabic, 2 cloves, 3 tablespoons sugar, 2
tablespoons lemon juice, 1 cup port wine. Stand in kettle cold water,
heat till all is dissolved. Strain into shallow dish. Chill. Cut in ½-inch
squares.