deep learning ian goodfellow yoshua bengio aaron courville

/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf


contents website vii acknowledgments viii notation xi 1 introduction 1 1. 1 who should read this book?.................... 8 1. 2 historical trends in deep learning................. 11 i applied math and machine learning basics 29 2 linear algebra 31 2. 1 scalars, vectors, matrices and tensors............... 31 2. 2 multiplying matrices and vectors.................. 34 2. 3 identity and inverse matrices.................... 36 2. 4 linear dependence and span.................... 37 2. 5 norms................................. 39 2. 6 special kinds of matrices and vectors..............


.......................... 39 2. 6 special kinds of matrices and vectors............... 40 2. 7 eigendecomposition.......................... 42 2. 8 singular value decomposition.................... 44 2. 9 the moore - penrose pseudoinverse.................. 45 2. 10 the trace operator......................... 46 2. 11 the determinant........................... 47 2. 12 example : principal components analysis............. 48 3 probability and information theory 53 3. 1 why probability?...........


.... 47 2. 12 example : principal components analysis............. 48 3 probability and information theory 53 3. 1 why probability?........................... 54 i


contents 3. 2 random variables.......................... 56 3. 3 probability distributions....................... 56 3. 4 marginal probability......................... 58 3. 5 conditional probability....................... 59 3. 6 the chain rule of conditional probabilities............ 59 3. 7 independence and conditional independence............ 60 3. 8 expectation, variance and covariance............... 60 3. 9 common probability distributions................. 62 3. 10 useful properties of common functions.............. 67 3. 11 bayes ’ rule..........


......... 62 3. 10 useful properties of common functions.............. 67 3. 11 bayes ’ rule.............................. 70 3. 12 technical details of continuous variables............. 71 3. 13 information theory.......................... 73 3. 14 structured probabilistic models................... 75 4 numerical computation 80 4. 1 overﬂow and underﬂow....................... 80 4. 2 poor conditioning.......................... 82 4. 3 gradient - based optimization.................... 82 4. 4 constrained


................. 82 4. 3 gradient - based optimization.................... 82 4. 4 constrained optimization...................... 93 4. 5 example : linear least squares................... 96 5 machine learning basics 98 5. 1 learning algorithms......................... 99 5. 2 capacity, overﬁtting and underﬁtting............... 110 5. 3 hyperparameters and validation sets................ 120 5. 4 estimators, bias and variance.................... 122 5. 5 maximum likelihood estimation.................. 131 5. 6 bayesian statistics.


................. 122 5. 5 maximum likelihood estimation.................. 131 5. 6 bayesian statistics.......................... 135 5. 7 supervised learning algorithms................... 140 5. 8 unsupervised learning algorithms................. 146 5. 9 stochastic gradient descent..................... 151 5. 10 building a machine learning algorithm.............. 153 5. 11 challenges motivating deep learning................ 155 ii deep networks : modern practices 166 6 deep feedforward networks 168 6. 1 example : learning xor....................... 171 6


.. 155 ii deep networks : modern practices 166 6 deep feedforward networks 168 6. 1 example : learning xor....................... 171 6. 2 gradient - based learning....................... 177 ii


contents 6. 3 hidden units............................. 191 6. 4 architecture design.......................... 197 6. 5 back - propagation and other [UNK] algorithms..... 204 6. 6 historical notes............................ 224 7 regularization for deep learning 228 7. 1 parameter norm penalties...................... 230 7. 2 norm penalties as constrained optimization............ 237 7. 3 regularization and under - constrained problems......... 239 7. 4 dataset augmentation........................ 240 7. 5 noise robustness......................


..................... 240 7. 5 noise robustness........................... 242 7. 6 semi - supervised learning...................... 243 7. 7 multi - task learning......................... 244 7. 8 early stopping............................ 246 7. 9 parameter tying and parameter sharing.............. 253 7. 10 sparse representations........................ 254 7. 11 bagging and other ensemble methods............... 256 7. 12 dropout....................


7. 11 bagging and other ensemble methods............... 256 7. 12 dropout................................ 258 7. 13 adversarial training......................... 268 7. 14 tangent distance, tangent prop, and manifold tangent classiﬁer 270 8 optimization for training deep models 274 8. 1 how learning [UNK] from pure optimization........... 275 8. 2 challenges in neural network optimization............ 282 8. 3 basic algorithms........................... 294 8. 4 parameter initialization strategies................. 301 8. 5 algorithms with adaptive learning rates............. 306 8. 6 approximate second - order methods.....


.............. 301 8. 5 algorithms with adaptive learning rates............. 306 8. 6 approximate second - order methods................ 310 8. 7 optimization strategies and meta - algorithms........... 317 9 convolutional networks 330 9. 1 the convolution operation..................... 331 9. 2 motivation............................... 335 9. 3 pooling................................. 339 9. 4 convolution and pooling as an inﬁnitely strong prior....... 345 9. 5 variants of the basic convolution function............ 347 9. 6 structured outputs.


##ing as an inﬁnitely strong prior....... 345 9. 5 variants of the basic convolution function............ 347 9. 6 structured outputs.......................... 358 9. 7 data types.............................. 360 9. 8 [UNK] convolution algorithms.................. 362 9. 9 random or unsupervised features................. 363 iii


contents 9. 10 the neuroscientiﬁc basis for convolutional networks....... 364 9. 11 convolutional networks and the history of deep learning.... 371 10 sequence modeling : recurrent and recursive nets 373 10. 1 unfolding computational graphs.................. 375 10. 2 recurrent neural networks..................... 378 10. 3 bidirectional rnns.......................... 394 10. 4 encoder - decoder sequence - to - sequence architectures....... 396 10. 5 deep recurrent networks...................... 398 10. 6 recursive neural networks...................... 400 10. 7 the challenge of long - term dependencies..


.... 398 10. 6 recursive neural networks...................... 400 10. 7 the challenge of long - term dependencies............. 401 10. 8 echo state networks......................... 404 10. 9 leaky units and other strategies for multiple time scales.... 406 10. 10 the long short - term memory and other gated rnns...... 408 10. 11 optimization for long - term dependencies............. 413 10. 12 explicit memory........................... 416 11 practical methodology 421 11. 1 performance metrics......................... 422 11. 2 default baseline models....................


....................... 422 11. 2 default baseline models....................... 425 11. 3 determining whether to gather more data............ 426 11. 4 selecting hyperparameters...................... 427 11. 5 debugging strategies......................... 436 11. 6 example : multi - digit number recognition............. 440 12 applications 443 12. 1 large - scale deep learning...................... 443 12. 2 computer vision........................... 452 12. 3 speech recognition..............


computer vision........................... 452 12. 3 speech recognition.......................... 458 12. 4 natural language processing.................... 461 12. 5 other applications.......................... 478 iii deep learning research 486 13 linear factor models 489 13. 1 probabilistic pca and factor analysis............... 490 13. 2 independent component analysis ( ica ).............. 491 13. 3 slow feature analysis........................ 493 13. 4 sparse coding............................


............... 493 13. 4 sparse coding............................. 496 iv


contents 13. 5 manifold interpretation of pca................... 499 14 autoencoders 502 14. 1 undercomplete autoencoders.................... 503 14. 2 regularized autoencoders...................... 504 14. 3 representational power, layer size and depth........... 508 14. 4 stochastic encoders and decoders.................. 509 14. 5 denoising autoencoders....................... 510 14. 6 learning manifolds with autoencoders............... 515 14. 7 contractive autoencoders...................... 521 14. 8


............. 515 14. 7 contractive autoencoders...................... 521 14. 8 predictive sparse decomposition.................. 523 14. 9 applications of autoencoders.................... 524 15 representation learning 526 15. 1 greedy layer - wise unsupervised pretraining........... 528 15. 2 transfer learning and domain adaptation............. 536 15. 3 semi - supervised disentangling of causal factors......... 541 15. 4 distributed representation...................... 546 15. 5 exponential gains from depth................... 553 15. 6 providing clues to discover underlying causes.....


...... 546 15. 5 exponential gains from depth................... 553 15. 6 providing clues to discover underlying causes.......... 554 16 structured probabilistic models for deep learning 558 16. 1 the challenge of unstructured modeling.............. 559 16. 2 using graphs to describe model structure............. 563 16. 3 sampling from graphical models.................. 580 16. 4 advantages of structured modeling................. 582 16. 5 learning about dependencies.................... 582 16. 6 inference and approximate inference................ 584 16. 7 the deep learning approach to structured probabilistic models 585 17 monte carlo methods 590 17. 1 sampling and monte carlo methods..


inference................ 584 16. 7 the deep learning approach to structured probabilistic models 585 17 monte carlo methods 590 17. 1 sampling and monte carlo methods................ 590 17. 2 importance sampling......................... 592 17. 3 markov chain monte carlo methods................ 595 17. 4 gibbs sampling............................ 599 17. 5 the challenge of mixing between separated modes........ 599 18 confronting the partition function 605 18. 1 the log - likelihood gradient.................... 606 18. 2 stochastic maximum likelihood and contrastive divergence... 607 v


contents 18. 3 pseudolikelihood........................... 615 18. 4 score matching and ratio matching................ 617 18. 5 denoising score matching...................... 619 18. 6 noise - contrastive estimation.................... 620 18. 7 estimating the partition function.................. 623 19 approximate inference 631 19. 1 inference as optimization...................... 633 19. 2 expectation maximization...................... 634 19. 3 map inference and sparse coding................. 635 19. 4 variational inference and learning....


......... 634 19. 3 map inference and sparse coding................. 635 19. 4 variational inference and learning................. 638 19. 5 learned approximate inference................... 651 20 deep generative models 654 20. 1 boltzmann machines......................... 654 20. 2 restricted boltzmann machines................... 656 20. 3 deep belief networks......................... 660 20. 4 deep boltzmann machines...................... 663 20. 5 boltzmann machines for real - valued data............. 676 20. 6


.................. 663 20. 5 boltzmann machines for real - valued data............. 676 20. 6 convolutional boltzmann machines................. 683 20. 7 boltzmann machines for structured or sequential outputs.... 685 20. 8 other boltzmann machines..................... 686 20. 9 back - propagation through random operations.......... 687 20. 10 directed generative nets....................... 692 20. 11 drawing samples from autoencoders................ 711 20. 12 generative stochastic networks................... 714 20. 13 other generation schemes............


711 20. 12 generative stochastic networks................... 714 20. 13 other generation schemes...................... 716 20. 14 evaluating generative models.................... 717 20. 15 conclusion............................... 720 bibliography 721 index 777 vi


website www. deeplearningbook. org this book is accompanied by the above website. the website provides a variety of supplementary material, including exercises, lecture slides, corrections of mistakes, and other resources that should be useful to both readers and instructors. vii


acknowledgments this book would not have been possible without the contributions of many people. we would like to thank those who commented on our proposal for the book and helped plan its contents and organization : guillaume alain, kyunghyun cho, caglar gulcehre, david krueger, hugo larochelle, razvan pascanu and thomas rohee. we would like to thank the people who [UNK] feedback on the content of the book itself. some [UNK] feedback on many chapters : martin abadi, guillaume alain, ion androutsopoulos, fred bertsch, olexa bilaniuk, ufuk can bicici, matko bosnjak, john boersma, greg brockman, alexandre de brebisson, pierre luc carrier, sarath chandar, pawel chilinski, mark daoust, oleg dashevskii, laurent dinh, stephan dreseitl, jim fan, miao fan, meire fortunato, frederic francis, nando de freitas, caglar gulcehre, jurgen van gael, javier alonso garcia, jonathan hunt, gopi jeyaram, chingiz kabytayev, lukasz kaiser, varun kanade


, frederic francis, nando de freitas, caglar gulcehre, jurgen van gael, javier alonso garcia, jonathan hunt, gopi jeyaram, chingiz kabytayev, lukasz kaiser, varun kanade, asifullah khan, akiel khan, john king, diederik p. kingma, yann lecun, rudolf mathey, matias mattamala, abhinav maurya, kevin murphy, oleg murk, roman novak, augustus q. odena, simon pavlik, karl pichotta, eddie pierce, kari pulli, roussel rahman, tapani raiko, anurag ranjan, johannes roith, mihaela rosca, halis sak, cesar salgado, grigory sapunov, yoshinori sasaki, mike schuster, julian serban, nir shabat, ken [UNK], andre simpelo, scott stanley, david sussillo, ilya sutskever, carles gelada saez, graham taylor, valentin tolmer, massimiliano tomassoli, an tran, shubhendu trivedi, alexey umnov, vincent vanhoucke, marco visent


##tskever, carles gelada saez, graham taylor, valentin tolmer, massimiliano tomassoli, an tran, shubhendu trivedi, alexey umnov, vincent vanhoucke, marco visentini - scarzanella, martin vita, david warde - farley, dustin webb, kelvin xu, wei xue, ke yang, li yao, zygmunt zajac and ozan caglayan. we would also like to thank those who provided us with useful feedback on individual chapters : • notation : zhang yuanhang. • chapter, : yusuf akgul, sebastien bratieres, samira ebrahimi, 1 introduction viii


contents charlie gorichanaz, brendan loudermilk, eric morris, cosmin parvulescu and alfredo solano. • chapter, : amjad almahairi, nikola banic, kevin bennett, 2 linear algebra philippe castonguay, oscar chang, eric fosler - lussier, andrey khalyavin, sergey oreshkov, istvan petras, dennis prangle, thomas rohee, gitanjali gulve sehgal, colby toland, alessandro vitale and bob welland. • chapter, : john philip anderson, kai 3 probability and information theory arulkumaran, vincent dumoulin, rui fa, stephan gouws, artem oboturov, antti rasmus, alexey surkov and volker tresp. • chapter, : tran lam anian fischer and hu 4 numerical computation yuhuang. • chapter, : dzmitry bahdanau, justin domingue, 5 machine learning basics nikhil garg, makoto otsuka, bob pepin, philip popien, emmanuel rayner, peter shepard, kee - bong song, zheng sun and andy wu. • chapter, 6 deep feedforward networks : ur


basics nikhil garg, makoto otsuka, bob pepin, philip popien, emmanuel rayner, peter shepard, kee - bong song, zheng sun and andy wu. • chapter, 6 deep feedforward networks : uriel berdugo, fabrizio bottarel, elizabeth burl, ishan durugkar, [UNK], jong wook kim, david krueger and aditya kumar praharaj. • chapter, : morten kolbæk, kshitij lauria, 7 regularization for deep learning inkyu lee, sunil mohan, hai phong phan and joshua salisbury. • chapter, 8 optimization for training deep models : marcel ackermann, peter armitage, rowel atienza, andrew brock, tegan maharaj, james martens, kashif rasul, klaus strobl and nicholas turner. • chapter, 9 convolutional networks : martin arjovsky, eugene brevdo, kon - stantin divilov, eric jensen, mehdi mirza, alex paino, marjorie sayer, ryan stout and wentao wu. • chapter, 10 sequence modeling : recurrent and recursive nets : gokcen eraslan


##n - stantin divilov, eric jensen, mehdi mirza, alex paino, marjorie sayer, ryan stout and wentao wu. • chapter, 10 sequence modeling : recurrent and recursive nets : gokcen eraslan, steven hickson, razvan pascanu, lorenzo von ritter, rui rodrigues, dmitriy serdyuk, dongyu shi and kaiyu yang. • chapter, : daniel beckstein. 11 practical methodology • chapter, : george dahl, vladimir nekrasov and ribana 12 applications roscher. • chapter, 13 linear factor models : jayanth koushik. ix


contents • chapter, : kunal ghosh. 15 representation learning • chapter, : minh le 16 structured probabilistic models for deep learning and anton varfolom. • chapter, 18 confronting the partition function : sam bowman. • chapter, : yujia bao. 19 approximate inference • chapter, 20 deep generative models : nicolas chapados, daniel galvez, wenming ma, fady medhat, shakir mohamed and gregoire montavon. • bibliography : lukas michelbacher and leslie n. smith. we also want to thank those who allowed us to reproduce images, ﬁgures or data from their publications. we indicate their contributions in the ﬁgure captions throughout the text. we would like to thank lu wang for writing pdf2htmlex, which we used to make the web version of the book, and for [UNK] support to improve the quality of the resulting html. we would like to thank ian ’ s wife daniela flori goodfellow for patiently supporting ian during the writing of the book as well as for help with proofreading. we would like to thank the google brain team for providing an intellectual environment where ian could devote a tremendous amount of time to writing this book and receive feedback and guidance from colleagues. we


writing of the book as well as for help with proofreading. we would like to thank the google brain team for providing an intellectual environment where ian could devote a tremendous amount of time to writing this book and receive feedback and guidance from colleagues. we would especially like to thank ian ’ s former manager, greg corrado, and his current manager, samy bengio, for their support of this project. finally, we would like to thank [UNK] hinton for encouragement when writing was [UNK]. x


notation this section provides a concise reference describing the notation used throughout this book. if you are unfamiliar with any of the corresponding mathematical concepts, we describe most of these ideas in chapters 2 – 4. numbers and arrays a a scalar ( integer or real ) a a vector a a matrix a a tensor in identity matrix with rows and columns n n i identity matrix with dimensionality implied by context e ( ) i standard basis vector [ 0,..., 0, 1, 0,..., 0 ] with a 1 at position i diag ( ) a a square, diagonal matrix with diagonal entries given by a a a scalar random variable a a vector - valued random variable a a matrix - valued random variable xi


contents sets and graphs a a set r the set of real numbers { } 0 1, the set containing 0 and 1 { } 0 1,,..., n the set of all integers between and 0 n [ ] a, b the real interval including and a b ( ] a, b the real interval excluding but including a b a b \ set subtraction, i. e., the set containing the ele - ments of that are not in a b g a graph pag ( xi ) the parents of xi in g indexing ai element i of vector a, with indexing starting at 1 a−i all elements of vector except for element a i ai, j element of matrix i, j a ai, : row of matrix i a a :, i column of matrix i a ai, j, k element of a 3 - d tensor ( ) i, j, k a a : :,, i 2 - d slice of a 3 - d tensor ai element of the random vector i a linear algebra operations a transpose of matrix a a + moore - penrose pseudoinverse of a a b element - wise ( hadamard ) product of and a b det ( ) a determinant of a xii


contents calculus dy dx derivative of with respect to y x ∂y ∂x partial derivative of with respect to y x ∇xy gradient of with respect to y x ∇x y matrix derivatives of with respect to y x ∇xy tensor containing derivatives of y with respect to x ∂f ∂x jacobian matrix j ∈rm n × of f : rn →rm ∇2 xf f f ( ) ( x or h ) ( ) x the hessian matrix of at input point x f d ( ) x x deﬁnite integral over the entire domain of x s f d ( ) x x x deﬁnite integral with respect to over the set s probability and information theory a b the random variables a and b are independent [UNK] a b c they are conditionally independent given c [UNK] | p ( ) a a probability distribution over a discrete variable p ( ) a a probability distribution over a continuous vari - able, or over a variable whose type has not been speciﬁed a random variable a has distribution [UNK] p [UNK] [ ( ) ] ( ) ( ) ( ) f x or ef x expectation of f x with respect to p x var ( ( ) ) f x variance of under x f x ( ) p ( ) cov


has distribution [UNK] p [UNK] [ ( ) ] ( ) ( ) ( ) f x or ef x expectation of f x with respect to p x var ( ( ) ) f x variance of under x f x ( ) p ( ) cov ( ( ) ( ) ) f x, g x covariance of and under x f x ( ) g x ( ) p ( ) h ( ) x shannon entropy of the random variable x dkl ( ) p q kullback - leibler divergence of p and q n ( ; ) x µ, σ gaussian distribution over x with mean µ and covariance σ xiii


contents functions f f : a b → the function with domain and range a b f g f g [UNK] composition of the functions and f ( ; ) x θ a function of x parametrized by θ. ( sometimes we write f ( x ) and omit the argument θ to lighten notation ) log x x natural logarithm of σ x ( ) logistic sigmoid, 1 1 + exp ( ) −x ζ x x ( ) log ( 1 + exp ( softplus, ) ) | | | | x p lp norm of x | | | | x l2 norm of x x + positive part of, i. e., x max ( 0 ), x 1condition is 1 if the condition is true, 0 otherwise sometimes we use a function f whose argument is a scalar but apply it to a vector, matrix, or tensor : f ( x ), f ( x ), or f ( x ). this denotes the application of f to the array element - wise. for example, if c = σ ( x ), then c i, j, k = σ ( xi, j, k ) for all valid values of, and. i j k datasets and distributions p data


array element - wise. for example, if c = σ ( x ), then c i, j, k = σ ( xi, j, k ) for all valid values of, and. i j k datasets and distributions p data the data generating distribution [UNK] the empirical distribution deﬁned by the training set x a set of training examples x ( ) i the - th example ( input ) from a dataset i y ( ) i or y ( ) i the target associated with x ( ) i for supervised learn - ing x the m n × matrix with input example x ( ) i in row xi, : xiv


chapter 1 introduction inventors have long dreamed of creating machines that think. this desire dates back to at least the time of ancient greece. the mythical ﬁgures pygmalion, daedalus, and hephaestus may all be interpreted as legendary inventors, and galatea, talos, and pandora may all be regarded as artiﬁcial life (, ovid and martin 2004 sparkes 1996 tandy 1997 ;, ;, ). when programmable computers were ﬁrst conceived, people wondered whether such machines might become intelligent, over a hundred years before one was built ( lovelace 1842, ). today, artiﬁcial intelligence ( ai ) is a thriving ﬁeld with many practical applications and active research topics. we look to intelligent software to automate routine labor, understand speech or images, make diagnoses in medicine and support basic scientiﬁc research. in the early days of artiﬁcial intelligence, the ﬁeld rapidly tackled and solved problems that are intellectually [UNK] for human beings but relatively straight - forward for computers — problems that can be described by a list of formal, math - ematical rules. the true challenge to artiﬁcial intelligence proved to be solving the tasks that are easy for people


[UNK] for human beings but relatively straight - forward for computers — problems that can be described by a list of formal, math - ematical rules. the true challenge to artiﬁcial intelligence proved to be solving the tasks that are easy for people to perform but hard for people to describe formally — problems that we solve intuitively, that feel automatic, like recognizing spoken words or faces in images. this book is about a solution to these more intuitive problems. this solution is to allow computers to learn from experience and understand the world in terms of a hierarchy of concepts, with each concept deﬁned in terms of its relation to simpler concepts. by gathering knowledge from experience, this approach avoids the need for human operators to formally specify all of the knowledge that the computer needs. the hierarchy of concepts allows the computer to learn complicated concepts by building them out of simpler ones. if we draw a graph showing how these 1


chapter 1. introduction concepts are built on top of each other, the graph is deep, with many layers. for this reason, we call this approach to ai. deep learning many of the early successes of ai took place in relatively sterile and formal environments and did not require computers to have much knowledge about the world. for example, ibm ’ s deep blue chess - playing system defeated world champion garry kasparov in 1997 (, ). chess is of course a very simple hsu 2002 world, containing only sixty - four locations and thirty - two pieces that can move in only rigidly circumscribed ways. devising a successful chess strategy is a tremendous accomplishment, but the challenge is not due to the [UNK] of describing the set of chess pieces and allowable moves to the computer. chess can be completely described by a very brief list of completely formal rules, easily provided ahead of time by the programmer. ironically, abstract and formal tasks that are among the most [UNK] mental undertakings for a human being are among the easiest for a computer. computers have long been able to defeat even the best human chess player, but are only recently matching some of the abilities of average human beings to recognize objects or speech. a person ’ s everyday life requires an immense amount of


the easiest for a computer. computers have long been able to defeat even the best human chess player, but are only recently matching some of the abilities of average human beings to recognize objects or speech. a person ’ s everyday life requires an immense amount of knowledge about the world. much of this knowledge is subjective and intuitive, and therefore [UNK] to articulate in a formal way. computers need to capture this same knowledge in order to behave in an intelligent way. one of the key challenges in artiﬁcial intelligence is how to get this informal knowledge into a computer. several artiﬁcial intelligence projects have sought to hard - code knowledge about the world in formal languages. a computer can reason about statements in these formal languages automatically using logical inference rules. this is known as the knowledge base approach to artiﬁcial intelligence. none of these projects has led to a major success. one of the most famous such projects is cyc (, lenat and guha 1989 ). cyc is an inference engine and a database of statements in a language called cycl. these statements are entered by a [UNK] human supervisors. it is an unwieldy process. people struggle to devise formal rules with enough complexity to accurately describe the world. for example, cyc failed to


statements in a language called cycl. these statements are entered by a [UNK] human supervisors. it is an unwieldy process. people struggle to devise formal rules with enough complexity to accurately describe the world. for example, cyc failed to understand a story about a person named fred shaving in the morning (, ). its inference linde 1992 engine detected an inconsistency in the story : it knew that people do not have electrical parts, but because fred was holding an electric razor, it believed the entity “ fredwhileshaving ” contained electrical parts. it therefore asked whether fred was still a person while he was shaving. the [UNK] faced by systems relying on hard - coded knowledge suggest that ai systems need the ability to acquire their own knowledge, by extracting patterns from raw data. this capability is known as machine learning. the 2


chapter 1. introduction introduction of machine learning allowed computers to tackle problems involving knowledge of the real world and make decisions that appear subjective. a simple machine learning algorithm called logistic regression can determine whether to recommend cesarean delivery ( mor - yosef 1990 et al., ). a simple machine learning algorithm called naive bayes can separate legitimate e - mail from spam e - mail. the performance of these simple machine learning algorithms depends heavily on the representation of the data they are given. for example, when logistic regression is used to recommend cesarean delivery, the ai system does not examine the patient directly. instead, the doctor tells the system several pieces of relevant information, such as the presence or absence of a uterine scar. each piece of information included in the representation of the patient is known as a feature. logistic regression learns how each of these features of the patient correlates with various outcomes. however, it cannot inﬂuence the way that the features are deﬁned in any way. if logistic regression was given an mri scan of the patient, rather than the doctor ’ s formalized report, it would not be able to make useful predictions. individual pixels in an mri scan have negligible correlation with any complications that might occur during delivery


##istic regression was given an mri scan of the patient, rather than the doctor ’ s formalized report, it would not be able to make useful predictions. individual pixels in an mri scan have negligible correlation with any complications that might occur during delivery. this dependence on representations is a general phenomenon that appears throughout computer science and even daily life. in computer science, opera - tions such as searching a collection of data can proceed exponentially faster if the collection is structured and indexed intelligently. people can easily perform arithmetic on arabic numerals, but ﬁnd arithmetic on roman numerals much more time - consuming. it is not surprising that the choice of representation has an enormous [UNK] on the performance of machine learning algorithms. for a simple visual example, see ﬁgure. 1. 1 many artiﬁcial intelligence tasks can be solved by designing the right set of features to extract for that task, then providing these features to a simple machine learning algorithm. for example, a useful feature for speaker identiﬁcation from sound is an estimate of the size of speaker ’ s vocal tract. it therefore gives a strong clue as to whether the speaker is a man, woman, or child. however, for many tasks, it is [UNK] to know what features should


##cation from sound is an estimate of the size of speaker ’ s vocal tract. it therefore gives a strong clue as to whether the speaker is a man, woman, or child. however, for many tasks, it is [UNK] to know what features should be extracted. for example, suppose that we would like to write a program to detect cars in photographs. we know that cars have wheels, so we might like to use the presence of a wheel as a feature. unfortunately, it is [UNK] to describe exactly what a wheel looks like in terms of pixel values. a wheel has a simple geometric shape but its image may be complicated by shadows falling on the wheel, the sun glaring [UNK] the metal parts of the wheel, the fender of the car or an object in the foreground obscuring part of the wheel, and so on. 3


chapter 1. introduction figure 1. 1 : example of [UNK] representations : suppose we want to separate two categories of data by drawing a line between them in a scatterplot. in the plot on the left, we represent some data using cartesian coordinates, and the task is impossible. in the plot on the right, we represent the data with polar coordinates and the task becomes simple to solve with a vertical line. figure produced in collaboration with david warde - farley. one solution to this problem is to use machine learning to discover not only the mapping from representation to output but also the representation itself. this approach is known as representation learning. learned representations often result in much better performance than can be obtained with hand - designed representations. they also allow ai systems to rapidly adapt to new tasks, with minimal human intervention. a representation learning algorithm can discover a good set of features for a simple task in minutes, or a complex task in hours to months. manually designing features for a complex task requires a great deal of human time and [UNK] ; it can take decades for an entire community of researchers. the quintessential example of a representation learning algorithm is the au - toencoder. an autoencoder is the combination of an encoder function that converts the


and [UNK] ; it can take decades for an entire community of researchers. the quintessential example of a representation learning algorithm is the au - toencoder. an autoencoder is the combination of an encoder function that converts the input data into a [UNK] representation, and a decoder function that converts the new representation back into the original format. autoencoders are trained to preserve as much information as possible when an input is run through the encoder and then the decoder, but are also trained to make the new representation have various nice properties. [UNK] kinds of autoencoders aim to achieve [UNK] kinds of properties. when designing features or algorithms for learning features, our goal is usually to separate the factors of variation that explain the observed data. in this context, we use the word “ factors ” simply to refer to separate sources of inﬂuence ; the factors are usually not combined by multiplication. such factors are often not 4


chapter 1. introduction quantities that are directly observed. instead, they may exist either as unobserved objects or unobserved forces in the physical world that [UNK] observable quantities. they may also exist as constructs in the human mind that provide useful simplifying explanations or inferred causes of the observed data. they can be thought of as concepts or abstractions that help us make sense of the rich variability in the data. when analyzing a speech recording, the factors of variation include the speaker ’ s age, their sex, their accent and the words that they are speaking. when analyzing an image of a car, the factors of variation include the position of the car, its color, and the angle and brightness of the sun. a major source of [UNK] in many real - world artiﬁcial intelligence applications is that many of the factors of variation inﬂuence every single piece of data we are able to observe. the individual pixels in an image of a red car might be very close to black at night. the shape of the car ’ s silhouette depends on the viewing angle. most applications require us to the factors of variation and discard the disentangle ones that we do not care about. of course, it can be very [UNK] to extract such


. the shape of the car ’ s silhouette depends on the viewing angle. most applications require us to the factors of variation and discard the disentangle ones that we do not care about. of course, it can be very [UNK] to extract such high - level, abstract features from raw data. many of these factors of variation, such as a speaker ’ s accent, can be identiﬁed only using sophisticated, nearly human - level understanding of the data. when it is nearly as [UNK] to obtain a representation as to solve the original problem, representation learning does not, at ﬁrst glance, seem to help us. deep learning solves this central problem in representation learning by intro - ducing representations that are expressed in terms of other, simpler representations. deep learning allows the computer to build complex concepts out of simpler con - cepts. figure shows how a deep learning system can represent the concept of 1. 2 an image of a person by combining simpler concepts, such as corners and contours, which are in turn deﬁned in terms of edges. the quintessential example of a deep learning model is the feedforward deep network or multilayer perceptron ( mlp ). a multilayer perceptron is just a


in turn deﬁned in terms of edges. the quintessential example of a deep learning model is the feedforward deep network or multilayer perceptron ( mlp ). a multilayer perceptron is just a mathematical function mapping some set of input values to output values. the function is formed by composing many simpler functions. we can think of each application of a [UNK] mathematical function as providing a new representation of the input. the idea of learning the right representation for the data provides one perspec - tive on deep learning. another perspective on deep learning is that depth allows the computer to learn a multi - step computer program. each layer of the representation can be thought of as the state of the computer ’ s memory after executing another set of instructions in parallel. networks with greater depth can execute more instructions in sequence. sequential instructions [UNK] great power because later 5


chapter 1. introduction visible layer ( input pixels ) 1st hidden layer ( edges ) 2nd hidden layer ( corners and contours ) 3rd hidden layer ( object parts ) car person animal output ( object identity ) figure 1. 2 : illustration of a deep learning model. it is [UNK] for a computer to understand the meaning of raw sensory input data, such as this image represented as a collection of pixel values. the function mapping from a set of pixels to an object identity is very complicated. learning or evaluating this mapping seems insurmountable if tackled directly. deep learning resolves this [UNK] by breaking the desired complicated mapping into a series of nested simple mappings, each described by a [UNK] layer of the model. the input is presented at the visible layer, so named because it contains the variables that we are able to observe. then a series of hidden layers extracts increasingly abstract features from the image. these layers are called “ hidden ” because their values are not given in the data ; instead the model must determine which concepts are useful for explaining the relationships in the observed data. the images here are visualizations of the kind of feature represented by each hidden unit. given the pixels, the ﬁrst layer can easily identify edges, by comparing the brightness of neighboring pixels. given the ﬁ


for explaining the relationships in the observed data. the images here are visualizations of the kind of feature represented by each hidden unit. given the pixels, the ﬁrst layer can easily identify edges, by comparing the brightness of neighboring pixels. given the ﬁrst hidden layer ’ s description of the edges, the second hidden layer can easily search for corners and extended contours, which are recognizable as collections of edges. given the second hidden layer ’ s description of the image in terms of corners and contours, the third hidden layer can detect entire parts of speciﬁc objects, by ﬁnding speciﬁc collections of contours and corners. finally, this description of the image in terms of the object parts it contains can be used to recognize the objects present in the image. images reproduced with permission from zeiler and fergus 2014 ( ). 6


chapter 1. introduction x1 x1 σ w1 w1 × x2 x2 w2 w2 × + element set + × σ x w element set logistic regression logistic regression figure 1. 3 : illustration of computational graphs mapping an input to an output where each node performs an operation. depth is the length of the longest path from input to output but depends on the deﬁnition of what constitutes a possible computational step. the computation depicted in these graphs is the output of a logistic regression model, σ ( wt x ), where σ is the logistic sigmoid function. if we use addition, multiplication and logistic sigmoids as the elements of our computer language, then this model has depth three. if we view logistic regression as an element itself, then this model has depth one. instructions can refer back to the results of earlier instructions. according to this view of deep learning, not all of the information in a layer ’ s activations necessarily encodes factors of variation that explain the input. the representation also stores state information that helps to execute a program that can make sense of the input. this state information could be analogous to a counter or pointer in a traditional computer program. it has nothing to do with the content of


explain the input. the representation also stores state information that helps to execute a program that can make sense of the input. this state information could be analogous to a counter or pointer in a traditional computer program. it has nothing to do with the content of the input speciﬁcally, but it helps the model to organize its processing. there are two main ways of measuring the depth of a model. the ﬁrst view is based on the number of sequential instructions that must be executed to evaluate the architecture. we can think of this as the length of the longest path through a ﬂow chart that describes how to compute each of the model ’ s outputs given its inputs. just as two equivalent computer programs will have [UNK] lengths depending on which language the program is written in, the same function may be drawn as a ﬂowchart with [UNK] depths depending on which functions we allow to be used as individual steps in the ﬂowchart. figure illustrates how this 1. 3 choice of language can give two [UNK] measurements for the same architecture. another approach, used by deep probabilistic models, regards the depth of a model as being not the depth of the computational graph but the depth of the graph describing how concepts are related to each other. in this case, the


same architecture. another approach, used by deep probabilistic models, regards the depth of a model as being not the depth of the computational graph but the depth of the graph describing how concepts are related to each other. in this case, the depth 7


chapter 1. introduction of the ﬂowchart of the computations needed to compute the representation of each concept may be much deeper than the graph of the concepts themselves. this is because the system ’ s understanding of the simpler concepts can be reﬁned given information about the more complex concepts. for example, an ai system observing an image of a face with one eye in shadow may initially only see one eye. after detecting that a face is present, it can then infer that a second eye is probably present as well. in this case, the graph of concepts only includes two layers — a layer for eyes and a layer for faces — but the graph of computations includes 2n layers if we reﬁne our estimate of each concept given the other times. n because it is not always clear which of these two views — the depth of the computational graph, or the depth of the probabilistic modeling graph — is most relevant, and because [UNK] people choose [UNK] sets of smallest elements from which to construct their graphs, there is no single correct value for the depth of an architecture, just as there is no single correct value for the length of a computer program. nor is there a consensus about how much depth a model requires to qualify as “ deep. ” however


, there is no single correct value for the depth of an architecture, just as there is no single correct value for the length of a computer program. nor is there a consensus about how much depth a model requires to qualify as “ deep. ” however, deep learning can safely be regarded as the study of models that either involve a greater amount of composition of learned functions or learned concepts than traditional machine learning does. to summarize, deep learning, the subject of this book, is an approach to ai. speciﬁcally, it is a type of machine learning, a technique that allows computer systems to improve with experience and data. according to the authors of this book, machine learning is the only viable approach to building ai systems that can operate in complicated, real - world environments. deep learning is a particular kind of machine learning that achieves great power and ﬂexibility by learning to represent the world as a nested hierarchy of concepts, with each concept deﬁned in relation to simpler concepts, and more abstract representations computed in terms of less abstract ones. figure illustrates the relationship between these [UNK] 1. 4 ai disciplines. figure gives a high - level schematic of how each works. 1. 5 1. 1 who should read this book? this book


representations computed in terms of less abstract ones. figure illustrates the relationship between these [UNK] 1. 4 ai disciplines. figure gives a high - level schematic of how each works. 1. 5 1. 1 who should read this book? this book can be useful for a variety of readers, but we wrote it with two main target audiences in mind. one of these target audiences is university students ( undergraduate or graduate ) learning about machine learning, including those who are beginning a career in deep learning and artiﬁcial intelligence research. the other target audience is software engineers who do not have a machine learning or statistics background, but want to rapidly acquire one and begin using deep learning in their product or platform. deep learning has already proven useful in 8


chapter 1. introduction ai machine learning representation learning deep learning example : knowledge bases example : logistic regression example : shallow autoencoders example : mlps figure 1. 4 : a venn diagram showing how deep learning is a kind of representation learning, which is in turn a kind of machine learning, which is used for many but not all approaches to ai. each section of the venn diagram includes an example of an ai technology. 9


chapter 1. introduction input hand - designed program output input hand - designed features mapping from features output input features mapping from features output input simple features mapping from features output additional layers of more abstract features rule - based systems classic machine learning representation learning deep learning figure 1. 5 : flowcharts showing how the [UNK] parts of an ai system relate to each other within [UNK] ai disciplines. shaded boxes indicate components that are able to learn from data. 10


chapter 1. introduction many software disciplines including computer vision, speech and audio processing, natural language processing, robotics, bioinformatics and chemistry, video games, search engines, online advertising and ﬁnance. this book has been organized into three parts in order to best accommodate a variety of readers. part introduces basic mathematical tools and machine learning i concepts. part describes the most established deep learning algorithms that are ii essentially solved technologies. part describes more speculative ideas that are iii widely believed to be important for future research in deep learning. readers should feel free to skip parts that are not relevant given their interests or background. readers familiar with linear algebra, probability, and fundamental machine learning concepts can skip part, for example, while readers who just want i to implement a working system need not read beyond part. to help choose which ii chapters to read, ﬁgure provides a ﬂowchart showing the high - level organization 1. 6 of the book. we do assume that all readers come from a computer science background. we assume familiarity with programming, a basic understanding of computational performance issues, complexity theory, introductory level calculus and some of the terminology of graph theory. 1. 2 historical trends in deep learning it is easiest to understand deep learning with some historical context. rather than providing


familiarity with programming, a basic understanding of computational performance issues, complexity theory, introductory level calculus and some of the terminology of graph theory. 1. 2 historical trends in deep learning it is easiest to understand deep learning with some historical context. rather than providing a detailed history of deep learning, we identify a few key trends : • deep learning has had a long and rich history, but has gone by many names reﬂecting [UNK] philosophical viewpoints, and has waxed and waned in popularity. • deep learning has become more useful as the amount of available training data has increased. • deep learning models have grown in size over time as computer infrastructure ( both hardware and software ) for deep learning has improved. • deep learning has solved increasingly complicated applications with increasing accuracy over time. 11


chapter 1. introduction 1. introduction part i : applied math and machine learning basics 2. linear algebra 3. probability and information theory 4. numerical computation 5. machine learning basics part ii : deep networks : modern practices 6. deep feedforward networks 7. regularization 8. optimization 9. cnns 10. rnns 11. practical methodology 12. applications part iii : deep learning research 13. linear factor models 14. autoencoders 15. representation learning 16. structured probabilistic models 17. monte carlo methods 18. partition function 19. inference 20. deep generative models figure 1. 6 : the high - level organization of the book. an arrow from one chapter to another indicates that the former chapter is prerequisite material for understanding the latter. 12


chapter 1. introduction 1. 2. 1 the many names and changing fortunes of neural net - works we expect that many readers of this book have heard of deep learning as an exciting new technology, and are surprised to see a mention of “ history ” in a book about an emerging ﬁeld. in fact, deep learning dates back to the 1940s. deep learning only appears to be new, because it was relatively unpopular for several years preceding its current popularity, and because it has gone through many [UNK] names, and has only recently become called “ deep learning. ” the ﬁeld has been rebranded many times, reﬂecting the inﬂuence of [UNK] researchers and [UNK] perspectives. a comprehensive history of deep learning is beyond the scope of this textbook. however, some basic context is useful for understanding deep learning. broadly speaking, there have been three waves of development of deep learning : deep learning known as cybernetics in the 1940s – 1960s, deep learning known as connectionism in the 1980s – 1990s, and the current resurgence under the name deep learning beginning in 2006. this is quantitatively illustrated in ﬁgure. 1. 7 some of the earliest learning algorithms we recognize today were intended to be computational models of biological learning, i. e. models of how learning happens


under the name deep learning beginning in 2006. this is quantitatively illustrated in ﬁgure. 1. 7 some of the earliest learning algorithms we recognize today were intended to be computational models of biological learning, i. e. models of how learning happens or could happen in the brain. as a result, one of the names that deep learning has gone by is artiﬁcial neural networks ( anns ). the corresponding perspective on deep learning models is that they are engineered systems inspired by the biological brain ( whether the human brain or the brain of another animal ). while the kinds of neural networks used for machine learning have sometimes been used to understand brain function (, ), they are hinton and shallice 1991 generally not designed to be realistic models of biological function. the neural perspective on deep learning is motivated by two main ideas. one idea is that the brain provides a proof by example that intelligent behavior is possible, and a conceptually straightforward path to building intelligence is to reverse engineer the computational principles behind the brain and duplicate its functionality. another perspective is that it would be deeply interesting to understand the brain and the principles that underlie human intelligence, so machine learning models that shed light on these basic scientiﬁc questions are useful apart from their ability to solve engineering


its functionality. another perspective is that it would be deeply interesting to understand the brain and the principles that underlie human intelligence, so machine learning models that shed light on these basic scientiﬁc questions are useful apart from their ability to solve engineering applications. the modern term “ deep learning ” goes beyond the neuroscientiﬁc perspective on the current breed of machine learning models. it appeals to a more general principle of learning multiple levels of composition, which can be applied in machine learning frameworks that are not necessarily neurally inspired. 13


chapter 1. introduction 1940 1950 1960 1970 1980 1990 2000 year 0. 000000 0. 000050 0. 000100 0. 000150 0. 000200 0. 000250 frequency of word or phrase cybernetics ( connectionism + neural networks ) figure 1. 7 : the ﬁgure shows two of the three historical waves of artiﬁcial neural nets research, as measured by the frequency of the phrases “ cybernetics ” and “ connectionism ” or “ neural networks ” according to google books ( the third wave is too recent to appear ). the ﬁrst wave started with cybernetics in the 1940s – 1960s, with the development of theories of biological learning (, ;, ) and implementations of mcculloch and pitts 1943 hebb 1949 the ﬁrst models such as the perceptron ( rosenblatt 1958, ) allowing the training of a single neuron. the second wave started with the connectionist approach of the 1980 – 1995 period, with back - propagation (, ) to train a neural network with one or two rumelhart et al. 1986a hidden layers. the current and third wave, deep learning, started around 2006 ( hinton et al. et al. et al., ; 2006


(, ) to train a neural network with one or two rumelhart et al. 1986a hidden layers. the current and third wave, deep learning, started around 2006 ( hinton et al. et al. et al., ; 2006 bengio, ; 2007 ranzato, ), and is just now appearing in book 2007a form as of 2016. the other two waves similarly appeared in book form much later than the corresponding scientiﬁc activity occurred. 14


chapter 1. introduction the earliest predecessors of modern deep learning were simple linear models motivated from a neuroscientiﬁc perspective. these models were designed to take a set of n input values x1,..., xn and associate them with an output y. these models would learn a set of weights w1,..., wn and compute their output f ( x w, ) = x1w1 + · · · + xnwn. this ﬁrst wave of neural networks research was known as cybernetics, as illustrated in ﬁgure. 1. 7 the mcculloch - pitts neuron (, ) was an early model mcculloch and pitts 1943 of brain function. this linear model could recognize two [UNK] categories of inputs by testing whether f ( x w, ) is positive or negative. of course, for the model to correspond to the desired deﬁnition of the categories, the weights needed to be set correctly. these weights could be set by the human operator. in the 1950s, the perceptron ( rosenblatt 1958 1962,, ) became the ﬁrst model that could learn the weights deﬁning the categories given examples of inputs from each category. the adaptive linear element (


the human operator. in the 1950s, the perceptron ( rosenblatt 1958 1962,, ) became the ﬁrst model that could learn the weights deﬁning the categories given examples of inputs from each category. the adaptive linear element ( adaline ), which dates from about the same time, simply returned the value of f ( x ) itself to predict a real number ( widrow and [UNK], ), and could also learn to predict these numbers from data. these simple learning algorithms greatly [UNK] the modern landscape of ma - chine learning. the training algorithm used to adapt the weights of the adaline was a special case of an algorithm called stochastic gradient descent. slightly modiﬁed versions of the stochastic gradient descent algorithm remain the dominant training algorithms for deep learning models today. models based on the f ( x w, ) used by the perceptron and adaline are called linear models. these models remain some of the most widely used machine learning models, though in many cases they are trained in [UNK] ways than the original models were trained. linear models have many limitations. most famously, they cannot learn the xor function, where f ( [ 0, 1 ], w ) = 1 and f ( [ 1, 0


they are trained in [UNK] ways than the original models were trained. linear models have many limitations. most famously, they cannot learn the xor function, where f ( [ 0, 1 ], w ) = 1 and f ( [ 1, 0 ], w ) = 1 but f ( [ 1, 1 ], w ) = 0 and f ( [ 0, 0 ], w ) = 0. critics who observed these ﬂaws in linear models caused a backlash against biologically inspired learning in general ( minsky and papert, 1969 ). this was the ﬁrst major dip in the popularity of neural networks. today, neuroscience is regarded as an important source of inspiration for deep learning researchers, but it is no longer the predominant guide for the ﬁeld. the main reason for the diminished role of neuroscience in deep learning research today is that we simply do not have enough information about the brain to use it as a guide. to obtain a deep understanding of the actual algorithms used by the brain, we would need to be able to monitor the activity of ( at the very least ) thousands of interconnected neurons simultaneously. because we are not able to do this, we are far from understanding even some of the most simple and 15


chapter 1. introduction well - studied parts of the brain (, ). olshausen and field 2005 neuroscience has given us a reason to hope that a single deep learning algorithm can solve many [UNK] tasks. neuroscientists have found that ferrets can learn to “ see ” with the auditory processing region of their brain if their brains are rewired to send visual signals to that area ( von melchner 2000 et al., ). this suggests that much of the mammalian brain might use a single algorithm to solve most of the [UNK] tasks that the brain solves. before this hypothesis, machine learning research was more fragmented, with [UNK] communities of researchers studying natural language processing, vision, motion planning and speech recognition. today, these application communities are still separate, but it is common for deep learning research groups to study many or even all of these application areas simultaneously. we are able to draw some rough guidelines from neuroscience. the basic idea of having many computational units that become intelligent only via their interactions with each other is inspired by the brain. the neocognitron ( fukushima 1980, ) introduced a powerful model architecture for processing images that was inspired by the structure of the mammalian visual system and later became the basis for the modern convolutional network


is inspired by the brain. the neocognitron ( fukushima 1980, ) introduced a powerful model architecture for processing images that was inspired by the structure of the mammalian visual system and later became the basis for the modern convolutional network (, ), as we will see in lecun et al. 1998b section. most neural networks today are based on a model neuron called 9. 10 the rectiﬁed linear unit. the original cognitron ( fukushima 1975, ) introduced a more complicated version that was highly inspired by our knowledge of brain function. the simpliﬁed modern version was developed incorporating ideas from many viewpoints, with ( ) and ( ) citing nair and hinton 2010 glorot et al. 2011a neuroscience as an inﬂuence, and ( ) citing more engineering - jarrett et al. 2009 oriented inﬂuences. while neuroscience is an important source of inspiration, it need not be taken as a rigid guide. we know that actual neurons compute very [UNK] functions than modern rectiﬁed linear units, but greater neural realism has not yet led to an improvement in machine learning performance. also, while neuroscience has successfully inspired several neural network architectures, we do not yet know enough about biological


compute very [UNK] functions than modern rectiﬁed linear units, but greater neural realism has not yet led to an improvement in machine learning performance. also, while neuroscience has successfully inspired several neural network architectures, we do not yet know enough about biological learning for neuroscience to [UNK] much guidance for the learning algorithms we use to train these architectures. media accounts often emphasize the similarity of deep learning to the brain. while it is true that deep learning researchers are more likely to cite the brain as an inﬂuence than researchers working in other machine learning ﬁelds such as kernel machines or bayesian statistics, one should not view deep learning as an attempt to simulate the brain. modern deep learning draws inspiration from many ﬁelds, especially applied math fundamentals like linear algebra, probability, information theory, and numerical optimization. while some deep learning researchers cite neuroscience as an important source of inspiration, others are not concerned with 16


chapter 1. introduction neuroscience at all. it is worth noting that the [UNK] to understand how the brain works on an algorithmic level is alive and well. this endeavor is primarily known as “ computational neuroscience ” and is a separate ﬁeld of study from deep learning. it is common for researchers to move back and forth between both ﬁelds. the ﬁeld of deep learning is primarily concerned with how to build computer systems that are able to successfully solve tasks requiring intelligence, while the ﬁeld of computational neuroscience is primarily concerned with building more accurate models of how the brain actually works. in the 1980s, the second wave of neural network research emerged in great part via a movement called connectionism or parallel distributed process - ing (, ;, ). connectionism arose in rumelhart et al. 1986c mcclelland et al. 1995 the context of cognitive science. cognitive science is an interdisciplinary approach to understanding the mind, combining multiple [UNK] levels of analysis. during the early 1980s, most cognitive scientists studied models of symbolic reasoning. despite their popularity, symbolic models were [UNK] to explain in terms of how the brain could actually implement them using neurons. the connectionists began to study models of cognition that could actually be grounded in neural implementations ( touretzky and minton 1985, )


despite their popularity, symbolic models were [UNK] to explain in terms of how the brain could actually implement them using neurons. the connectionists began to study models of cognition that could actually be grounded in neural implementations ( touretzky and minton 1985, ), reviving many ideas dating back to the work of psychologist donald hebb in the 1940s (, ). hebb 1949 the central idea in connectionism is that a large number of simple computational units can achieve intelligent behavior when networked together. this insight applies equally to neurons in biological nervous systems and to hidden units in computational models. several key concepts arose during the connectionism movement of the 1980s that remain central to today ’ s deep learning. one of these concepts is that of distributed representation ( hinton et al., 1986 ). this is the idea that each input to a system should be represented by many features, and each feature should be involved in the representation of many possible inputs. for example, suppose we have a vision system that can recognize cars, trucks, and birds and these objects can each be red, green, or blue. one way of representing these inputs would be to have a separate neuron or hidden unit that activates for each of the nine possible combinations : red truck, red car, red bird


birds and these objects can each be red, green, or blue. one way of representing these inputs would be to have a separate neuron or hidden unit that activates for each of the nine possible combinations : red truck, red car, red bird, green truck, and so on. this requires nine [UNK] neurons, and each neuron must independently learn the concept of color and object identity. one way to improve on this situation is to use a distributed representation, with three neurons describing the color and three neurons describing the object identity. this requires only six neurons total instead of nine, and the neuron describing redness is able to 17


chapter 1. introduction learn about redness from images of cars, trucks and birds, not only from images of one speciﬁc category of objects. the concept of distributed representation is central to this book, and will be described in greater detail in chapter. 15 another major accomplishment of the connectionist movement was the suc - cessful use of back - propagation to train deep neural networks with internal repre - sentations and the popularization of the back - propagation algorithm ( rumelhart et al., ;, ). this algorithm has waxed and waned in popularity 1986a lecun 1987 but as of this writing is currently the dominant approach to training deep models. during the 1990s, researchers made important advances in modeling sequences with neural networks. ( ) and ( ) identiﬁed some of hochreiter 1991 bengio et al. 1994 the fundamental mathematical [UNK] in modeling long sequences, described in section. 10. 7 hochreiter and schmidhuber 1997 ( ) introduced the long short - term memory or lstm network to resolve some of these [UNK]. today, the lstm is widely used for many sequence modeling tasks, including many natural language processing tasks at google. the second wave of neural networks research lasted until the


short - term memory or lstm network to resolve some of these [UNK]. today, the lstm is widely used for many sequence modeling tasks, including many natural language processing tasks at google. the second wave of neural networks research lasted until the mid - 1990s. ven - tures based on neural networks and other ai technologies began to make unrealisti - cally ambitious claims while seeking investments. when ai research did not fulﬁll these unreasonable expectations, investors were disappointed. simultaneously, other ﬁelds of machine learning made advances. kernel machines (, boser et al. 1992 cortes and vapnik 1995 scholkopf 1999 jor - ;, ; et al., ) and graphical models ( dan 1998, ) both achieved good results on many important tasks. these two factors led to a decline in the popularity of neural networks that lasted until 2007. during this time, neural networks continued to obtain impressive performance on some tasks (, ;, ). the canadian institute lecun et al. 1998b bengio et al. 2001 for advanced research ( cifar ) helped to keep neural networks research alive via its neural computation and adaptive perception ( ncap ) research initiative. this program united machine learning research groups led by [UNK] hinton


al. 1998b bengio et al. 2001 for advanced research ( cifar ) helped to keep neural networks research alive via its neural computation and adaptive perception ( ncap ) research initiative. this program united machine learning research groups led by [UNK] hinton at university of toronto, yoshua bengio at university of montreal, and yann lecun at new york university. the cifar ncap research initiative had a multi - disciplinary nature that also included neuroscientists and experts in human and computer vision. at this point in time, deep networks were generally believed to be very [UNK] to train. we now know that algorithms that have existed since the 1980s work quite well, but this was not apparent circa 2006. the issue is perhaps simply that these algorithms were too computationally costly to allow much experimentation with the hardware available at the time. the third wave of neural networks research began with a breakthrough in 18


chapter 1. introduction 2006. [UNK] hinton showed that a kind of neural network called a deep belief network could be [UNK] trained using a strategy called greedy layer - wise pre - training (, ), which will be described in more detail in section. hinton et al. 2006 15. 1 the other cifar - [UNK] research groups quickly showed that the same strategy could be used to train many other kinds of deep networks (, ; bengio et al. 2007 ranzato 2007a et al., ) and systematically helped to improve generalization on test examples. this wave of neural networks research popularized the use of the term “ deep learning ” to emphasize that researchers were now able to train deeper neural networks than had been possible before, and to focus attention on the theoretical importance of depth (, ;, bengio and lecun 2007 delalleau and bengio 2011 pascanu 2014a montufar 2014 ; et al., ; et al., ). at this time, deep neural networks outperformed competing ai systems based on other machine learning technologies as well as hand - designed functionality. this third wave of popularity of neural networks continues to the time of this writing, though the focus of deep learning research has changed dramatically within the time of this wave


##formed competing ai systems based on other machine learning technologies as well as hand - designed functionality. this third wave of popularity of neural networks continues to the time of this writing, though the focus of deep learning research has changed dramatically within the time of this wave. the third wave began with a focus on new unsupervised learning techniques and the ability of deep models to generalize well from small datasets, but today there is more interest in much older supervised learning algorithms and the ability of deep models to leverage large labeled datasets. 1. 2. 2 increasing dataset sizes one may wonder why deep learning has only recently become recognized as a crucial technology though the ﬁrst experiments with artiﬁcial neural networks were conducted in the 1950s. deep learning has been successfully used in commercial applications since the 1990s, but was often regarded as being more of an art than a technology and something that only an expert could use, until recently. it is true that some skill is required to get good performance from a deep learning algorithm. fortunately, the amount of skill required reduces as the amount of training data increases. the learning algorithms reaching human performance on complex tasks today are nearly identical to the learning algorithms that struggled to solve toy problems in the 1980s, though the models we train with


. fortunately, the amount of skill required reduces as the amount of training data increases. the learning algorithms reaching human performance on complex tasks today are nearly identical to the learning algorithms that struggled to solve toy problems in the 1980s, though the models we train with these algorithms have undergone changes that simplify the training of very deep architectures. the most important new development is that today we can provide these algorithms with the resources they need to succeed. figure shows how the size of benchmark 1. 8 datasets has increased remarkably over time. this trend is driven by the increasing digitization of society. as more and more of our activities take place on computers, more and more of what we do is recorded. as our computers are increasingly networked together, it becomes easier to centralize these records and curate them 19


chapter 1. introduction into a dataset appropriate for machine learning applications. the age of “ big data ” has made machine learning much easier because the key burden of statistical estimation — generalizing well to new data after observing only a small amount of data — has been considerably lightened. as of 2016, a rough rule of thumb is that a supervised deep learning algorithm will generally achieve acceptable performance with around 5, 000 labeled examples per category, and will match or exceed human performance when trained with a dataset containing at least 10 million labeled examples. working successfully with datasets smaller than this is an important research area, focusing in particular on how we can take advantage of large quantities of unlabeled examples, with unsupervised or semi - supervised learning. 1. 2. 3 increasing model sizes another key reason that neural networks are wildly successful today after enjoying comparatively little success since the 1980s is that we have the computational resources to run much larger models today. one of the main insights of connection - ism is that animals become intelligent when many of their neurons work together. an individual neuron or small collection of neurons is not particularly useful. biological neurons are not especially densely connected. as seen in ﬁgure, 1. 10 our machine learning models have had a


animals become intelligent when many of their neurons work together. an individual neuron or small collection of neurons is not particularly useful. biological neurons are not especially densely connected. as seen in ﬁgure, 1. 10 our machine learning models have had a number of connections per neuron that was within an order of magnitude of even mammalian brains for decades. in terms of the total number of neurons, neural networks have been astonishingly small until quite recently, as shown in ﬁgure. since the introduction of hidden 1. 11 units, artiﬁcial neural networks have doubled in size roughly every 2. 4 years. this growth is driven by faster computers with larger memory and by the availability of larger datasets. larger networks are able to achieve higher accuracy on more complex tasks. this trend looks set to continue for decades. unless new technologies allow faster scaling, artiﬁcial neural networks will not have the same number of neurons as the human brain until at least the 2050s. biological neurons may represent more complicated functions than current artiﬁcial neurons, so biological neural networks may be even larger than this plot portrays. in retrospect, it is not particularly surprising that neural networks with fewer neurons than a leech were unable to solve sophisticated artiﬁcial intelligence


current artiﬁcial neurons, so biological neural networks may be even larger than this plot portrays. in retrospect, it is not particularly surprising that neural networks with fewer neurons than a leech were unable to solve sophisticated artiﬁcial intelligence prob - lems. even today ’ s networks, which we consider quite large from a computational systems point of view, are smaller than the nervous system of even relatively primitive vertebrate animals like frogs. the increase in model size over time, due to the availability of faster cpus, 20


chapter 1. introduction 1900 1950 1985 2000 2015 100 101 102 103 104 105 106 107 108 109 dataset size ( number examples ) iris mnist public svhn imagenet cifar - 10 imagenet10k ilsvrc 2014 sports - 1m rotated t vs. c t vs. g vs. f criminals canadian hansard wmt figure 1. 8 : dataset sizes have increased greatly over time. in the early 1900s, statisticians studied datasets using hundreds or thousands of manually compiled measurements (, garson 1900 gosset 1908 anderson 1935 fisher 1936 ;, ;, ;, ). in the 1950s through 1980s, the pioneers of biologically inspired machine learning often worked with small, synthetic datasets, such as low - resolution bitmaps of letters, that were designed to incur low computational cost and demonstrate that neural networks were able to learn speciﬁc kinds of functions ( widrow and [UNK] rumelhart 1986b, ; et al., ). in the 1980s and 1990s, machine learning became more statistical in nature and began to leverage larger datasets containing tens of thousands of examples such as the mnist dataset ( shown in ﬁgure ) of scans 1. 9 of handwritten numbers (, )


and 1990s, machine learning became more statistical in nature and began to leverage larger datasets containing tens of thousands of examples such as the mnist dataset ( shown in ﬁgure ) of scans 1. 9 of handwritten numbers (, ). in the ﬁrst decade of the 2000s, more lecun et al. 1998b sophisticated datasets of this same size, such as the cifar - 10 dataset ( krizhevsky and hinton 2009, ) continued to be produced. toward the end of that decade and throughout the ﬁrst half of the 2010s, signiﬁcantly larger datasets, containing hundreds of thousands to tens of millions of examples, completely changed what was possible with deep learning. these datasets included the public street view house numbers dataset (, netzer et al. 2011 ), various versions of the imagenet dataset (,, ; deng et al. 2009 2010a russakovsky et al. et al., ), and the sports - 1m dataset ( 2014a karpathy, ). at the top of the 2014 graph, we see that datasets of translated sentences, such as ibm ’ s dataset constructed from the canadian hansard (, ) and the


- 1m dataset ( 2014a karpathy, ). at the top of the 2014 graph, we see that datasets of translated sentences, such as ibm ’ s dataset constructed from the canadian hansard (, ) and the wmt 2014 english to french brown et al. 1990 dataset ( schwenk 2014, ) are typically far ahead of other dataset sizes. 21


chapter 1. introduction figure 1. 9 : example inputs from the mnist dataset. the “ nist ” stands for national institute of standards and technology, the agency that originally collected this data. the “ m ” stands for “ modiﬁed, ” since the data has been preprocessed for easier use with machine learning algorithms. the mnist dataset consists of scans of handwritten digits and associated labels describing which digit 0 – 9 is contained in each image. this simple classiﬁcation problem is one of the simplest and most widely used tests in deep learning research. it remains popular despite being quite easy for modern techniques to solve. [UNK] hinton has described it as “ the drosophila of machine learning, ” meaning that it allows machine learning researchers to study their algorithms in controlled laboratory conditions, much as biologists often study fruit ﬂies. 22


chapter 1. introduction the advent of general purpose gpus ( described in section ), faster network 12. 1. 2 connectivity and better software infrastructure for distributed computing, is one of the most important trends in the history of deep learning. this trend is generally expected to continue well into the future. 1. 2. 4 increasing accuracy, complexity and real - world impact since the 1980s, deep learning has consistently improved in its ability to provide accurate recognition or prediction. moreover, deep learning has consistently been applied with success to broader and broader sets of applications. the earliest deep models were used to recognize individual objects in tightly cropped, extremely small images (, ). since then there has rumelhart et al. 1986a been a gradual increase in the size of images neural networks could process. modern object recognition networks process rich high - resolution photographs and do not have a requirement that the photo be cropped near the object to be recognized (, ). similarly, the earliest networks could only recognize krizhevsky et al. 2012 two kinds of objects ( or in some cases, the absence or presence of a single kind of object ), while these modern networks typically recognize at least 1, 000 [UNK] categories of objects. the largest contest in object recognition is the imagenet large scale


two kinds of objects ( or in some cases, the absence or presence of a single kind of object ), while these modern networks typically recognize at least 1, 000 [UNK] categories of objects. the largest contest in object recognition is the imagenet large scale visual recognition challenge ( ilsvrc ) held each year. a dramatic moment in the meteoric rise of deep learning came when a convolutional network won this challenge for the ﬁrst time and by a wide margin, bringing down the state - of - the - art top - 5 error rate from 26. 1 % to 15. 3 % (, ), krizhevsky et al. 2012 meaning that the convolutional network produces a ranked list of possible categories for each image and the correct category appeared in the ﬁrst ﬁve entries of this list for all but 15. 3 % of the test examples. since then, these competitions are consistently won by deep convolutional nets, and as of this writing, advances in deep learning have brought the latest top - 5 error rate in this contest down to 3. 6 %, as shown in ﬁgure. 1. 12 deep learning has also had a dramatic impact on speech recognition. after improving throughout the 1990s, the error


learning have brought the latest top - 5 error rate in this contest down to 3. 6 %, as shown in ﬁgure. 1. 12 deep learning has also had a dramatic impact on speech recognition. after improving throughout the 1990s, the error rates for speech recognition stagnated starting in about 2000. the introduction of deep learning (, ; dahl et al. 2010 deng et al. et al. et al., ; 2010b seide, ; 2011 hinton, ) to speech recognition resulted 2012a in a sudden drop of error rates, with some error rates cut in half. we will explore this history in more detail in section. 12. 3 deep networks have also had spectacular successes for pedestrian detection and image segmentation (, ; sermanet et al. 2013 farabet 2013 couprie et al., ; et al., 2013 ) and yielded superhuman performance in [UNK] sign classiﬁcation ( ciresan 23


chapter 1. introduction 1950 1985 2000 2015 101 102 103 104 connections per neuron 1 2 3 4 5 6 7 8 9 10 fruit ﬂy mouse cat human figure 1. 10 : initially, the number of connections between neurons in artiﬁcial neural networks was limited by hardware capabilities. today, the number of connections between neurons is mostly a design consideration. some artiﬁcial neural networks have nearly as many connections per neuron as a cat, and it is quite common for other neural networks to have as many connections per neuron as smaller mammals like mice. even the human brain does not have an exorbitant amount of connections per neuron. biological neural network sizes from ( ). wikipedia 2015 1. adaptive linear element (, ) widrow and [UNK] 2. neocognitron ( fukushima 1980, ) 3. gpu - accelerated convolutional network (, ) chellapilla et al. 2006 4. deep boltzmann machine ( salakhutdinov and hinton 2009a, ) 5. unsupervised convolutional network (, ) jarrett et al. 2009 6. gpu - accelerated multilayer perceptron (, ) ciresan et al. 2010 7.


##on 2009a, ) 5. unsupervised convolutional network (, ) jarrett et al. 2009 6. gpu - accelerated multilayer perceptron (, ) ciresan et al. 2010 7. distributed autoencoder (, ) le et al. 2012 8. multi - gpu convolutional network (, ) krizhevsky et al. 2012 9. cots hpc unsupervised convolutional network (, ) coates et al. 2013 10. googlenet (, ) szegedy et al. 2014a 24


chapter 1. introduction et al., ). 2012 at the same time that the scale and accuracy of deep networks has increased, so has the complexity of the tasks that they can solve. ( ) goodfellow et al. 2014d showed that neural networks could learn to output an entire sequence of characters transcribed from an image, rather than just identifying a single object. previously, it was widely believed that this kind of learning required labeling of the individual elements of the sequence (, ). recurrent neural networks, gulcehre and bengio 2013 such as the lstm sequence model mentioned above, are now used to model relationships between sequences sequences and other rather than just ﬁxed inputs. this sequence - to - sequence learning seems to be on the cusp of revolutionizing another application : machine translation ( sutskever 2014 bahdanau et al., ; et al., 2015 ). this trend of increasing complexity has been pushed to its logical conclusion with the introduction of neural turing machines ( graves 2014a et al., ) that learn to read from memory cells and write arbitrary content to memory cells. such neural networks can learn simple programs from examples of desired behavior. for example, they can learn to sort lists of numbers given examples of scrambled and sorted sequences


al., ) that learn to read from memory cells and write arbitrary content to memory cells. such neural networks can learn simple programs from examples of desired behavior. for example, they can learn to sort lists of numbers given examples of scrambled and sorted sequences. this self - programming technology is in its infancy, but in the future could in principle be applied to nearly any task. another crowning achievement of deep learning is its extension to the domain of reinforcement learning. in the context of reinforcement learning, an autonomous agent must learn to perform a task by trial and error, without any guidance from the human operator. deepmind demonstrated that a reinforcement learning system based on deep learning is capable of learning to play atari video games, reaching human - level performance on many tasks (, ). deep learning has mnih et al. 2015 also signiﬁcantly improved the performance of reinforcement learning for robotics (, ). finn et al. 2015 many of these applications of deep learning are highly proﬁtable. deep learning is now used by many top technology companies including google, microsoft, facebook, ibm, baidu, apple, adobe, netﬂix, nvidia and nec. advances in deep learning have also depended heavily on advances in software infrastructure. software libraries such as theano


many top technology companies including google, microsoft, facebook, ibm, baidu, apple, adobe, netﬂix, nvidia and nec. advances in deep learning have also depended heavily on advances in software infrastructure. software libraries such as theano (, ; bergstra et al. 2010 bastien et al. et al., ), pylearn2 ( 2012 goodfellow, ), torch (, ), 2013c collobert et al. 2011b distbelief (, ), [UNK] (, ), mxnet (, ), and dean et al. 2012 jia 2013 chen et al. 2015 tensorflow (, ) have all supported important research projects or abadi et al. 2015 commercial products. deep learning has also made contributions back to other sciences. modern convolutional networks for object recognition provide a model of visual processing 25


chapter 1. introduction that neuroscientists can study (, ). deep learning also provides useful dicarlo 2013 tools for processing massive amounts of data and making useful predictions in scientiﬁc ﬁelds. it has been successfully used to predict how molecules will interact in order to help pharmaceutical companies design new drugs (, ), dahl et al. 2014 to search for subatomic particles (, ), and to automatically parse baldi et al. 2014 microscope images used to construct a 3 - d map of the human brain ( knowles - barley 2014 et al., ). we expect deep learning to appear in more and more scientiﬁc ﬁelds in the future. in summary, deep learning is an approach to machine learning that has drawn heavily on our knowledge of the human brain, statistics and applied math as it developed over the past several decades. in recent years, it has seen tremendous growth in its popularity and usefulness, due in large part to more powerful com - puters, larger datasets and techniques to train deeper networks. the years ahead are full of challenges and opportunities to improve deep learning even further and bring it to new frontiers. 26


chapter 1. introduction 1950 1985 2000 2015 2056 10−2 10−1 100 101 102 103 104 105 106 107 108 109 1010 1011 number of neurons ( logarithmic scale ) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 sponge roundworm leech ant bee frog octopus human figure 1. 11 : since the introduction of hidden units, artiﬁcial neural networks have doubled in size roughly every 2. 4 years. biological neural network sizes from ( ). wikipedia 2015 1. perceptron (,, ) rosenblatt 1958 1962 2. adaptive linear element (, ) widrow and [UNK] 3. neocognitron ( fukushima 1980, ) 4. early back - propagation network (, ) rumelhart et al. 1986b 5. recurrent neural network for speech recognition ( robinson and fallside 1991, ) 6. multilayer perceptron for speech recognition (, ) bengio et al. 1991 7. mean ﬁeld sigmoid belief network (, ) saul et al. 1996 8. lenet - 5 (, ) lecun et al. 1998b 9. echo state network (, ) jaeger and haas 2004 10. deep belief network


ﬁeld sigmoid belief network (, ) saul et al. 1996 8. lenet - 5 (, ) lecun et al. 1998b 9. echo state network (, ) jaeger and haas 2004 10. deep belief network (, ) hinton et al. 2006 11. gpu - accelerated convolutional network (, ) chellapilla et al. 2006 12. deep boltzmann machine ( salakhutdinov and hinton 2009a, ) 13. gpu - accelerated deep belief network (, ) raina et al. 2009 14. unsupervised convolutional network (, ) jarrett et al. 2009 15. gpu - accelerated multilayer perceptron (, ) ciresan et al. 2010 16. omp - 1 network (, ) coates and ng 2011 17. distributed autoencoder (, ) le et al. 2012 18. multi - gpu convolutional network (, ) krizhevsky et al. 2012 19. cots hpc unsupervised convolutional network (, ) coates et al. 2013 20. googlenet (, ) szegedy et al.


, ) krizhevsky et al. 2012 19. cots hpc unsupervised convolutional network (, ) coates et al. 2013 20. googlenet (, ) szegedy et al. 2014a 27


chapter 1. introduction 2010 2011 2012 2013 2014 2015 0 00. 0 05. 0 10. 0 15. 0 20. 0 25. 0 30. ilsvrc classiﬁcation error rate figure 1. 12 : since deep networks reached the scale necessary to compete in the imagenet large scale visual recognition challenge, they have consistently won the competition every year, and yielded lower and lower error rates each time. data from russakovsky et al. et al. ( ) and 2014b he ( ). 2015 28


part i applied math and machine learning basics 29


this part of the book introduces the basic mathematical concepts needed to understand deep learning. we begin with general ideas from applied math that allow us to deﬁne functions of many variables, ﬁnd the highest and lowest points on these functions and quantify degrees of belief. next, we describe the fundamental goals of machine learning. we describe how to accomplish these goals by specifying a model that represents certain beliefs, designing a cost function that measures how well those beliefs correspond with reality and using a training algorithm to minimize that cost function. this elementary framework is the basis for a broad variety of machine learning algorithms, including approaches to machine learning that are not deep. in the subsequent parts of the book, we develop deep learning algorithms within this framework. 30


chapter 2 linear algebra linear algebra is a branch of mathematics that is widely used throughout science and engineering. however, because linear algebra is a form of continuous rather than discrete mathematics, many computer scientists have little experience with it. a good understanding of linear algebra is essential for understanding and working with many machine learning algorithms, especially deep learning algorithms. we therefore precede our introduction to deep learning with a focused presentation of the key linear algebra prerequisites. if you are already familiar with linear algebra, feel free to skip this chapter. if you have previous experience with these concepts but need a detailed reference sheet to review key formulas, we recommend the matrix cookbook ( petersen and pedersen 2006, ). if you have no exposure at all to linear algebra, this chapter will teach you enough to read this book, but we highly recommend that you also consult another resource focused exclusively on teaching linear algebra, such as shilov 1977 ( ). this chapter will completely omit many important linear algebra topics that are not essential for understanding deep learning. 2. 1 scalars, vectors, matrices and tensors the study of linear algebra involves several types of mathematical objects : • scalars : a scalar is just a single number, in contrast to most of the other objects studied in linear algebra,


2. 1 scalars, vectors, matrices and tensors the study of linear algebra involves several types of mathematical objects : • scalars : a scalar is just a single number, in contrast to most of the other objects studied in linear algebra, which are usually arrays of multiple numbers. we write scalars in italics. we usually give scalars lower - case variable names. when we introduce them, we specify what kind of number they are. for 31


chapter 2. linear algebra example, we might say “ let s ∈r be the slope of the line, ” while deﬁning a real - valued scalar, or “ let n ∈n be the number of units, ” while deﬁning a natural number scalar. • vectors : a vector is an array of numbers. the numbers are arranged in order. we can identify each individual number by its index in that ordering. typically we give vectors lower case names written in bold typeface, such as x. the elements of the vector are identiﬁed by writing its name in italic typeface, with a subscript. the ﬁrst element of x is x1, the second element is x2 and so on. we also need to say what kind of numbers are stored in the vector. if each element is in r, and the vector has n elements, then the vector lies in the set formed by taking the cartesian product of r n times, denoted as rn. when we need to explicitly identify the elements of a vector, we write them as a column enclosed in square brackets : x = x1 x2... xn. ( 2. 1 ) we can think of vectors as identifying points in space, with each


to explicitly identify the elements of a vector, we write them as a column enclosed in square brackets : x = x1 x2... xn. ( 2. 1 ) we can think of vectors as identifying points in space, with each element giving the coordinate along a [UNK] axis. sometimes we need to index a set of elements of a vector. in this case, we deﬁne a set containing the indices and write the set as a subscript. for example, to access x1, x3 and x6, we deﬁne the set s = { 1, 3, 6 } and write xs. we use the −sign to index the complement of a set. for example x−1 is the vector containing all elements of x except for x1, and x−s is the vector containing all of the elements of except for x x1, x3 and x6. • matrices : a matrix is a 2 - d array of numbers, so each element is identiﬁed by two indices instead of just one. we usually give matrices upper - case variable names with bold typeface, such as a. if a real - valued matrix a has a height of m and a width of n, then we say that a


##ed by two indices instead of just one. we usually give matrices upper - case variable names with bold typeface, such as a. if a real - valued matrix a has a height of m and a width of n, then we say that a ∈rm n ×. we usually identify the elements of a matrix using its name in italic but not bold font, and the indices are listed with separating commas. for example, a1 1, is the upper left entry of a and am, n is the bottom right entry. we can identify all of the numbers with vertical coordinate i by writing a “ ” for the horizontal : coordinate. for example, ai, : denotes the horizontal cross section of a with vertical coordinate i. this is known as the i - th row of a. likewise, a :, i is 32


chapter 2. linear algebra a = a1 1, a1 2, a2 1, a2 2, a3 1, a3 2, ⇒a = a1 1, a2 1, a3 1, a1 2, a2 2, a3 2, figure 2. 1 : the transpose of the matrix can be thought of as a mirror image across the main diagonal. the - th of. when we need to explicitly identify the elements of i column a a matrix, we write them as an array enclosed in square brackets : a1 1, a1 2, a2 1, a2 2,. ( 2. 2 ) sometimes we may need to index matrix - valued expressions that are not just a single letter. in this case, we use subscripts after the expression, but do not convert anything to lower case. for example, f ( a ) i, j gives element ( i, j ) of the matrix computed by applying the function to. f a • tensors : in some cases we will need an array with more than two axes. in the general case, an array of numbers arranged on a regular grid with a variable number of axes is known as a tensor. we denote a tensor named “ a ” with this typeface : a. we identify the element of


than two axes. in the general case, an array of numbers arranged on a regular grid with a variable number of axes is known as a tensor. we denote a tensor named “ a ” with this typeface : a. we identify the element of a at coordinates ( i, j, k ) by writing ai, j, k. one important operation on matrices is the transpose. the transpose of a matrix is the mirror image of the matrix across a diagonal line, called the main diagonal, running down and to the right, starting from its upper left corner. see ﬁgure for a graphical depiction of this operation. we denote the transpose of a 2. 1 matrix as a a, and it is deﬁned such that ( a ) i, j = aj, i. ( 2. 3 ) vectors can be thought of as matrices that contain only one column. the transpose of a vector is therefore a matrix with only one row. sometimes we 33


chapter 2. linear algebra deﬁne a vector by writing out its elements in the text inline as a row matrix, then using the transpose operator to turn it into a standard column vector, e. g., x = [ x1, x2, x3 ]. a scalar can be thought of as a matrix with only a single entry. from this, we can see that a scalar is its own transpose : a a =. we can add matrices to each other, as long as they have the same shape, just by adding their corresponding elements : where c a b = + ci, j = ai, j + b i, j. we can also add a scalar to a matrix or multiply a matrix by a scalar, just by performing that operation on each element of a matrix : d = a · b + c where di, j = a b · i, j + c. in the context of deep learning, we also use some less conventional notation. we allow the addition of matrix and a vector, yielding another matrix : c = a + b, where ci, j = ai, j + bj. in other words, the vector b is added to each row of the matrix. this shorthand eliminate