PDF Deep Learning with JavaScript: Neural networks in TensorFlow.js 1st Edition Shanqing Cai download
PDF Deep Learning with JavaScript: Neural networks in TensorFlow.js 1st Edition Shanqing Cai download
com
https://textbookfull.com/product/deep-learning-with-
javascript-neural-networks-in-tensorflow-js-1st-edition-
shanqing-cai/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/matlab-deep-learning-with-machine-
learning-neural-networks-and-artificial-intelligence-1st-edition-phil-
kim/
textboxfull.com
https://textbookfull.com/product/applied-neural-networks-with-
tensorflow-2-api-oriented-deep-learning-with-python-orhan-gazi-yalcin/
textboxfull.com
https://textbookfull.com/product/neural-networks-and-deep-learning-a-
textbook-charu-c-aggarwal/
textboxfull.com
Applied Neural Networks with TensorFlow 2 API Oriented
Deep Learning with Python 1st Edition Orhan Gazi Yalc■n
Yalç■n Orhan
https://textbookfull.com/product/applied-neural-networks-with-
tensorflow-2-api-oriented-deep-learning-with-python-1st-edition-orhan-
gazi-yalcin-yalcin-orhan/
textboxfull.com
https://textbookfull.com/product/practical-tensorflow-js-deep-
learning-in-web-app-development-juan-de-dios-santos-rivera/
textboxfull.com
Shanqing Cai
Stanley Bileschi
Eric D. Nielsen
François Chollet
Foreword by
Nikhil Thorat and Daniel Smilkov
MANNING
Working with data
Visualize data
Sect. 7.1
Images or data that can be represented 2D convolution and pooling Chapters 4 and 5
as images (e.g., audio, game board)
Binary classification Sigmoid binaryCrossentropy Accuracy, precision, Sect. 3.1, 3.2, 9.2
(making a binary decision) recall, sensitivity, TPR,
FPR, ROC, AUC
Multi-class classification Softmax categoricalCrossentropy Accuracy, confusion Sect. 3.3, 9.3
(deciding among multiple matrix
classes)
A mix of the above (for example, (Multiple) Custom loss function (multiple) Sect. 5.2
numbers plus classes)
SHANQING CAI
STANLEY BILESCHI
ERIC D. NIELSEN
WITH FRANÇOIS CHOLLET
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.
ISBN 9781617296178
Printed in the United States of America
brief contents
PART 1 MOTIVATION AND BASIC CONCEPTS . .................................1
1 ■ Deep learning and JavaScript 3
v
contents
foreword xiii
preface xv
acknowledgments xvii
about this book xix
about the authors xxii
about the cover illustration xxiii
vii
viii CONTENTS
TensorFlow.js 38
Project overview: Duration prediction 38 A note on code listings
■
Creating a new model using outputs from the base model 161
Getting the most out of transfer learning through fine-tuning: An
audio example 174
5.2 Object detection through transfer learning on a
convnet 185
A simple object-detection problem based on synthesized scenes 186
Deep dive into simple object detection 187
datasets 210
6.2 Training models with model.fitDataset 214
x CONTENTS
tf.data.microphone() 228
6.4 Your data is likely flawed: Dealing with problems
in your data 230
Theory of data 231 ■
Detecting and cleaning problems with
data 235
6.5 Data augmentation 242
algorithm 381
11.3 Value networks and Q-learning: The snake game
example 389
Snake as a reinforcement-learning problem 389 Markov decision
■
1
C. Cai and P. Guo, (2019) “Software Developers Learning Machine Learning: Motivations, Hurdles, and
Desires,” IEEE Symposium on Visual Languages and Human-Centric Computing, 2019.
xiii
xiv FOREWORD
xv
xvi PREFACE
xvii
xviii ACKNOWLEDGMENTS
Nikhil Thorat, Daniel Smilkov, Jamie Smith, Brian K. Lee, and Augustus Odena, as
well as by in-depth discussion with Suharsh Sivakumar.
One of the unique pleasures of working on a project such as TensorFlow.js is the
opportunity to work alongside and interact with the worldwide open-source software
community. TensorFlow.js was fortunate to have a group of talented and driven con-
tributors including Manraj Singh, Kai Sasaki, Josh Gartman, Sasha Illarionov, David
Sanders, syt123450@, and many many others, whose tireless work on the library
expanded its capability and improved its quality. Manraj Singh also contributed the
phishing-detection example used in chapter 3 of the book.
We are grateful to our editorial team at Manning Publications. The dedicated and
tireless work by Brian Sawyer, Jennifer Stout, Rebecca Rinehart, and Mehmed Pasic,
and many others made it possible for we authors to focus on writing the content.
Marc-Philip Huget provided extensive and incisive technical review throughout the
development process. Special thanks go to our reviewers, Alain Lompo, Andreas Refs-
gaard, Buu Nguyen, David DiMaria, Edin Kapic, Edwin Kwok, Eoghan O’Donnell,
Evan Wallace, George thomas, Giuliano Bertoti, Jason Hales, Marcio Nicolau, Michael
Wall, Paulo Nuin, Pietro Maffi, Polina Keselman, Prabhuti Prakash, Ryan Burrows,
Satej Sahu, Suresh Rangarajulu, Ursin Stauss, and Vaijanath Rao, whose suggestions
helped make this a better book.
We thank our MEAP readers for catching and pointing out quite a few typographi-
cal and technical errors.
Finally, none of this would be possible without the tremendous understanding and
sacrifice on the part of our families. Shanqing Cai would like to express the deepest
gratitude to his wife, Wei, as well as his parents and parents-in-law for their help and
support during this book’s year-long writing process. Stan Bileschi would like to thank
his mother and father, as well as his step-mother and step-father, for providing a foun-
dation and direction to build a successful career in science and engineering. He
would also like to thank his wife, Constance, for her love and support. Eric Nielsen
would like to say to his friends and family, thank you.
about this book
Who should read this book
This book is written for programmers who have a working knowledge of JavaScript,
from prior experience with either web frontend development or Node.js-based back-
end development, and wish to venture into the world of deep learning. It aims to sat-
isfy the learning needs of the following two subgroups of readers:
JavaScript programmers who aspire to go from little-to-no experience with
machine learning or its mathematical background, to a decent knowledge of
how deep learning works and a practical understanding of the deep-learning
workflow that is sufficient for solving common data-science problems such as
classification and regression
Web or Node.js developers who are tasked with deploying pre-trained models in
their web app or backend stack as new features
For the first group of readers, this book develops the basic concepts of machine learn-
ing and deep learning in a ground-up fashion, using JavaScript code examples that
are fun and ready for fiddling and hacking. We use diagrams, pseudo-code, and con-
crete examples in lieu of formal mathematics to help you form an intuitive, yet firm,
grasp of the foundations of how deep learning works.
For the second group of readers, we cover the key steps of converting existing
models (e.g., from Python training libraries) into a web- and/or Node-compatible for-
mat suitable for deployment in the frontend or the Node stack. We emphasize practi-
cal aspects such as optimizing model size and performance, as well as considerations
for various deployment environments ranging from a server to browser extensions
and mobile apps.
xix
xx ABOUT THIS BOOK
This book provides in-depth coverage of the TensorFlow.js API for ingesting and
formatting data, for building and loading models, and for running inference, evalua-
tion, and training for all readers.
Finally, technically minded people who don’t code regularly in JavaScript or any
other language will also find this book useful as an introductory text for both basic
and advanced neural networks.
xxii
about the cover illustration
The figure on the cover of Deep Learning with JavaScript is captioned “Finne Katschin,”
or a girl from the Katschin tribe. The illustration is taken from a collection of dress
costumes from various countries by Jacques Grasset de Saint-Sauveur (1757-1810),
titled Costumes de Différents Pays, published in France in 1797. Each illustration is finely
drawn and colored by hand. The rich variety of Grasset de Saint-Sauveur’s collection
reminds us vividly of how culturally apart the world’s towns and regions were just 200
years ago. Isolated from each other, people spoke different dialects and languages. In
the streets or in the countryside, it was easy to identify where they lived and what their
trade or station in life was just by their dress.
The way we dress has changed since then and the diversity by region, so rich at the
time, has faded away. It is now hard to tell apart the inhabitants of different conti-
nents, let alone different towns, regions, or countries. Perhaps we have traded cultural
diversity for a more varied personal life—certainly for a more varied and fast-paced
technological life.
At a time when it is hard to tell one computer book from another, Manning cele-
brates the inventiveness and initiative of the computer business with book covers
based on the rich diversity of regional life of two centuries ago, brought back to life by
Grasset de Saint-Sauveur’s pictures.
xxiii
Part 1
Motivation
and basic concepts
P art 1 consists of a single chapter that orients you to the basic concepts that
will form the backdrop for the rest of the book. These include artificial intelli-
gence, machine learning, and deep learning and the relations between them.
Chapter 1 also addresses the value and potential of practicing deep learning in
JavaScript.
Deep learning
and JavaScript
All the buzz around artificial intelligence (AI) is happening for a good reason: the
deep-learning revolution, as it is sometimes called, has indeed happened. Deep-
learning revolution refers to the rapid progress made in the speed and techniques of
deep neural networks that started around 2012 and is still ongoing. Since then,
deep neural networks have been applied to an increasingly wide range of prob-
lems, enabling machines to solve previously unsolvable problems in some cases and
dramatically improving solution accuracy in others (see table 1.1 for examples). To
experts in AI, many of these breakthroughs in neural networks were stunning.
3
Discovering Diverse Content Through
Random Scribd Documents
and Lawgiver of his church, hath a visible kingdom which he
exerciseth in and over the church visible by its spiritual office-
bearers, given to it as a church, and therefore distinct from, and
independent upon, the civil power—the keys of the kingdom of
heaven being by him committed, not to the magistrates, but to the
apostles’ successors in the work of the ministry.” He therefore
quitted the Established Church, betook himself to the fields, and
shared in the labours and obloquy of the persecuted. Mr Burnet was
prevented by sickness from personally bearing witness to the same
high prerogatives of Christ; but he left his reasons for refusing to
submit to any temporal supremacy in writing, and died rejoicing in
the hope of the glory of God. His last words were—“Glory! glory!
glory!”
It deserves to be remarked, that he and several other
distinguished ministers, although they had no liberty to accept of the
indulgence themselves, yet they did not deem it a reason why they
should withdraw their affection from those who had, or throw any
obstacles in the way of those they considered messengers of the
gospel; for these worthies thought preaching salvation to sinners so
paramount a duty, that they would have ventured upon every thing
but sin to have achieved it themselves or promoted it by others.
Charles and his advisers in attempting to introduce despotism, had
as little consulted their own peace as that of his kingdom. He was
harassed by his English parliament; and Lauderdale having been
voted a public grievance, was glad to seek refuge in Scotland,
where, in the month of December, he came down to hold a fourth
session of the parliament. Suspecting no opposition, if he secured
the support of the clergy, he told the estates that the most effectual
course would be taken for curbing and suppressing the insolent field
conventicles, and other seditious practices, which had so much
abounded—that if fairness would not, force must compel the
refractory to be peaceable and to obey the laws. But instead of his
declarations being met with the submissive adulation they were
wont, the Duke of Hamilton, supported by a strong party, presented
their grievances; and when the Commissioner with his usual haughty
roughness interposed to silence complaint, Sir Patrick Home of
Polwart demanded to know, whether it was not a free parliament?
And after a short tumultuous session, in which, amid the dissensions
of the statesmen, the Presbyterians escaped for the time any severer
enactment, the meeting was adjourned, and the parties sought each
to justify the strife to the king. Hamilton repaired to London and laid
a statement of the enormous abuses before his majesty, but only
received fair promises that were never performed, and incurred a
resentment that never was appeased. Lauderdale retained his
situation, and rather increased in favour with the king.
[1674.] It is a melancholy and an appalling consideration for those
who stand forward as reformers and patriots, that, in struggles for
religion, for liberty, or for any good principle, those who sincerely
strive to gain such objects are usually found in a minority at last;
and when they have been the means of conferring the most
essential benefits upon the country, they are generally left losers
themselves. Amid the conflicts of the statesmen, and their loud
complaints about the oppression and ruin of the country, no mention
had been made of the primary and most palpable of all its
distresses, the religious grievances of the Presbyterians:—those
which in fact had been the origin of all the calamities of Scotland,
and the triumph of which was to secure the cause of freedom, were
utterly lost sight of in their miserable squabbling about the monopoly
of salt and the smuggling of brandy.
Both Hamilton and Lauderdale were supposed friendly to the
persecuted; and while the nation was convulsed with their political
contentions, and their attention was sufficiently employed
elsewhere, the pious, resolute, and consistent part of the persecuted
ministers improved the respite for proclaiming peace upon the
mountains, bringing good tidings of good, publishing salvation, and
saying to Zion, “Thy God reigneth!” Conventicles increased both in
number and frequency. They began early in the year, and the
indefatigable Mr Blackadder beat up the primate’s quarters upon the
2d day of January.[76] On that day he collected at Kinkel, within a
mile of St Andrews, a large auditory, which filled the long gallery and
two chambers, besides a great number standing without doors. He
lectured on the second Psalm, a portion of Scripture remarkably
applicable, and preached from Jer. xiii. 18. The primate’s wife
hearing of the assembly, sent for the militia, who were fully prepared
in warlike array, under a Lieutenant Doig, accompanied by a great
number of the rascality, with many of the worst set of scholars from
the college and some noblemen’s sons. They drew up at a distance
from the gate, before which stood the laird, his brother, and the
minister’s eldest son; but they caused no interruption till the lecture
was finished and the psalm sung, when some people called out that
there was an alarm; on which the service stopped and the men
ranged outside the gate with the laird. Meanwhile, some of the
rabble had got into the stable and were carrying off the laird’s horse,
which he observing, aimed a blow at the fellow who had him; but
some of the “ill-set schollars” laying hold on his cane, a struggle
ensued, and the laird fell. Mr Welsh, who was also there, and
Kinkel’s brother, instantly drew; and the Lieutenant and his men
seeing them so resolute, and supposing that they were well
supported, fell back, nor dared approach sufficiently near the gate to
discover their error. Mrs Murray then went up to the Lieutenant and
asked him why he came in that hostile manner to trouble their house
on the Lord’s day? He said he had an order, which she requesting to
see, he told her he would show it to the laird; and, attended by a
sergeant, was drawing near the gate, when Mr Murray called, as he
approached—“How is it, Lieutenant, that you come to disturb us on
the Sabbath day?” In great trepidation he delivered the laird an
order which had been subscribed by the Chancellor about a year
before for apprehending him and his brother. When Kinkel had read
it, “I see,” said he, “you have an old order from the Chancellor to
that effect, which was extorted from him by the prelate. If you mind
to execute it now, you may, but you shall see the faces of men.” The
Lieutenant, grievously alarmed, cursed himself if he had a mind to
execute it. After which, the lady caused bring forth some ale for the
Lieutenant and his men; but one of them, whose companion had
been a little hurt, said he would drink none of her drink; he would
rather drink her heart’s blood. The rest partook of the refreshments
and went away. Composure being restored, the minister proceeded
with his sermon, and the whole closed in peace.
76. About the same time, the precise date is uncertain, Crail, where Sharpe had
been a Presbyterian minister, was visited by Mr John Dickson; and the
unhappy apostate was tormented by the sound of the gospel on his right
hand and on his left, while he vainly strove by military force to destroy the
faith which once he preached.
78. “One day a paper was fixt upon the Parliament House door, containing
upwards of one hundred persons, whose escheats were to be sold to any
who would purchase them.” Wodrow, vol. i. p. 384.
A.D. 1674-1676.
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