text
stringlengths 35
1.54k
| source
stringclasses 1
value | page
int64 1
800
| book
stringclasses 1
value | chunk_index
int64 0
0
|
|---|---|---|---|---|
z log [UNK] y yz ( ) = ( 6. 20 ) [UNK] y yz ( ) = exp ( ) ( 6. 21 ) p y ( ) = exp ( ) yz 1 y = 0 exp ( yz ) ( 6. 22 ) p y σ y z. ( ) = ( ( 2 −1 ) ) ( 6. 23 ) probability distributions based on exponentiation and normalization are common throughout the statistical modeling literature. the z variable defining such a distribution over binary variables is called a. logit this approach to predicting the probabilities in log - space is natural to use with maximum likelihood learning. because the cost function used with maximum likelihood is −log p ( y | x ), the log in the cost function undoes the exp of the sigmoid. without this [UNK], the saturation of the sigmoid could prevent gradient - based learning from making good progress. the loss function for maximum likelihood learning of a bernoulli parametrized by a sigmoid is j p y ( ) = log θ − ( | x ) ( 6. 24 ) = log ( ( 2 1 ) ) − σ y − z ( 6. 25 ) = ( ( 1 2 ) )
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 198
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
##rized by a sigmoid is j p y ( ) = log θ − ( | x ) ( 6. 24 ) = log ( ( 2 1 ) ) − σ y − z ( 6. 25 ) = ( ( 1 2 ) ) ζ −y z. ( 6. 26 ) this derivation makes use of some properties from section. by rewriting 3. 10 the loss in terms of the softplus function, we can see that it saturates only when ( 1 −2y ) z is very negative. saturation thus occurs only when the model already has the right answer — when y = 1 and z is very positive, or y = 0 and z is very negative. when z has the wrong sign, the argument to the softplus function, 183
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 198
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks ( 1 −2y ) z, may be simplified to | | z. as | | z becomes large while z has the wrong sign, the softplus function asymptotes toward simply returning its argument | | z. the derivative with respect to z asymptotes to sign ( z ), so, in the limit of extremely incorrect z, the softplus function does not shrink the gradient at all. this property is very useful because it means that gradient - based learning can act to quickly correct a mistaken. z when we use other loss functions, such as mean squared error, the loss can saturate anytime σ ( z ) saturates. the sigmoid activation function saturates to 0 when z becomes very negative and saturates to when 1 z becomes very positive. the gradient can shrink too small to be useful for learning whenever this happens, whether the model has the correct answer or the incorrect answer. for this reason, maximum likelihood is almost always the preferred approach to training sigmoid output units. analytically, the logarithm of the sigmoid is always defined and finite, because the sigmoid returns values restricted
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 199
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
this reason, maximum likelihood is almost always the preferred approach to training sigmoid output units. analytically, the logarithm of the sigmoid is always defined and finite, because the sigmoid returns values restricted to the open interval ( 0, 1 ), rather than using the entire closed interval of valid probabilities [ 0, 1 ]. in software implementations, to avoid numerical problems, it is best to write the negative log - likelihood as a function of z, rather than as a function of [UNK] = σ ( z ). if the sigmoid function underflows to zero, then taking the logarithm of [UNK] yields negative infinity. 6. 2. 2. 3 softmax units for multinoulli output distributions any time we wish to represent a probability distribution over a discrete variable with n possible values, we may use the softmax function. this can be seen as a generalization of the sigmoid function which was used to represent a probability distribution over a binary variable. softmax functions are most often used as the output of a classifier, to represent the probability distribution over n [UNK] classes. more rarely, softmax functions can be used inside the model itself, if we
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 199
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
probability distribution over a binary variable. softmax functions are most often used as the output of a classifier, to represent the probability distribution over n [UNK] classes. more rarely, softmax functions can be used inside the model itself, if we wish the model to choose between one of n [UNK] options for some internal variable. in the case of binary variables, we wished to produce a single number [UNK] p y. = ( = 1 ) | x ( 6. 27 ) because this number needed to lie between and, and because we wanted the 0 1 logarithm of the number to be well - behaved for gradient - based optimization of the log - likelihood, we chose to instead predict a number z = log [UNK] ( y = 1 | x ). exponentiating and normalizing gave us a bernoulli distribution controlled by the sigmoid function. 184
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 199
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks to generalize to the case of a discrete variable with n values, we now need to produce a vector [UNK], with [UNK] = p ( y = i | x ). we require not only that each element of [UNK] be between and, but also that the entire vector sums to so that 0 1 1 it represents a valid probability distribution. the same approach that worked for the bernoulli distribution generalizes to the multinoulli distribution. first, a linear layer predicts unnormalized log probabilities : z w = h b +, ( 6. 28 ) where zi = log [UNK] ( y = i | x ). the softmax function can then exponentiate and normalize to obtain the desired z [UNK]. formally, the softmax function is given by softmax ( ) z i = exp ( zi ) j exp ( zj ). ( 6. 29 ) as with the logistic sigmoid, the use of the exp function works very well when training the softmax to output a target value y using maximum log - likelihood. in this case, we wish to maximize log p ( y = i ; z ) = log softmax ( z ) i. de
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 200
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
exp function works very well when training the softmax to output a target value y using maximum log - likelihood. in this case, we wish to maximize log p ( y = i ; z ) = log softmax ( z ) i. defining the softmax in terms of exp is natural because the log in the log - likelihood can undo the of the softmax : exp log softmax ( ) z i = zi −log j exp ( zj ). ( 6. 30 ) the first term of equation shows that the input 6. 30 zi always has a direct contribution to the cost function. because this term cannot saturate, we know that learning can proceed, even if the contribution of zi to the second term of equation becomes very small. when maximizing the log - likelihood, the first 6. 30 term encourages zi to be pushed up, while the second term encourages all ofz to be pushed down. to gain some intuition for the second term, log j exp ( zj ), observe that this term can be roughly approximated by maxj zj. this approximation is based on the idea that exp ( zk ) is insignificant for any zk
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 200
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
, log j exp ( zj ), observe that this term can be roughly approximated by maxj zj. this approximation is based on the idea that exp ( zk ) is insignificant for any zk that is noticeably less than maxj zj. the intuition we can gain from this approximation is that the negative log - likelihood cost function always strongly penalizes the most active incorrect prediction. if the correct answer already has the largest input to the softmax, then the −zi term and the log j exp ( zj ) ≈maxj zj = zi terms will roughly cancel. this example will then contribute little to the overall training cost, which will be dominated by other examples that are not yet correctly classified. so far we have discussed only a single example. overall, unregularized maximum likelihood will drive the model to learn parameters that drive the softmax to predict 185
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 200
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks the fraction of counts of each outcome observed in the training set : softmax ( ( ; ) ) z x θ i ≈ m j = 1 1y ( ) j = i, x ( ) j = x m j = 1 1x ( ) j = x. ( 6. 31 ) because maximum likelihood is a consistent estimator, this is guaranteed to happen so long as the model family is capable of representing the training distribution. in practice, limited model capacity and imperfect optimization will mean that the model is only able to approximate these fractions. many objective functions other than the log - likelihood do not work as well with the softmax function. specifically, objective functions that do not use a log to undo the exp of the softmax fail to learn when the argument to the exp becomes very negative, causing the gradient to vanish. in particular, squared error is a poor loss function for softmax units, and can fail to train the model to change its output, even when the model makes highly confident incorrect predictions (, bridle 1990 ). to understand why these other loss functions can fail, we need to examine the softmax function itself. like the sigmoid, the
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 201
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
change its output, even when the model makes highly confident incorrect predictions (, bridle 1990 ). to understand why these other loss functions can fail, we need to examine the softmax function itself. like the sigmoid, the softmax activation can saturate. the sigmoid function has a single output that saturates when its input is extremely negative or extremely positive. in the case of the softmax, there are multiple output values. these output values can saturate when the [UNK] between input values become extreme. when the softmax saturates, many cost functions based on the softmax also saturate, unless they are able to invert the saturating activating function. to see that the softmax function responds to the [UNK] between its inputs, observe that the softmax output is invariant to adding the same scalar to all of its inputs : softmax ( ) = softmax ( + ) z z c. ( 6. 32 ) using this property, we can derive a numerically stable variant of the softmax : softmax ( ) = softmax ( max z z − i zi ). ( 6. 33 ) the reformulated version allows us to evaluate softmax with only small numerical errors even
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 201
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
can derive a numerically stable variant of the softmax : softmax ( ) = softmax ( max z z − i zi ). ( 6. 33 ) the reformulated version allows us to evaluate softmax with only small numerical errors even when z contains extremely large or extremely negative numbers. ex - amining the numerically stable variant, we see that the softmax function is driven by the amount that its arguments deviate from maxizi. an output softmax ( z ) i saturates to when the corresponding input is maximal 1 ( zi = maxizi ) and zi is much greater than all of the other inputs. the output softmax ( z ) i can also saturate to when 0 zi is not maximal and the maximum is much greater. this is a generalization of the way that sigmoid units saturate, and 186
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 201
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks can cause similar [UNK] for learning if the loss function is not designed to compensate for it. the argument z to the softmax function can be produced in two [UNK] ways. the most common is simply to have an earlier layer of the neural network output every element of z, as described above using the linear layer z = w h + b. while straightforward, this approach actually overparametrizes the distribution. the constraint that the n outputs must sum to means that only 1 n −1 parameters are necessary ; the probability of the n - th value may be obtained by subtracting the first n−1 1 probabilities from. we can thus impose a requirement that one element of z be fixed. for example, we can require that zn = 0. indeed, this is exactly what the sigmoid unit does. defining p ( y = 1 | x ) = σ ( z ) is equivalent to defining p ( y = 1 | x ) = softmax ( z ) 1 with a two - dimensional z and z1 = 0. both the n −1 argument and the n argument approaches to the softmax can describe the same set of probability distributions, but have [UNK] learning dynamics. in
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 202
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
= softmax ( z ) 1 with a two - dimensional z and z1 = 0. both the n −1 argument and the n argument approaches to the softmax can describe the same set of probability distributions, but have [UNK] learning dynamics. in practice, there is rarely much [UNK] between using the overparametrized version or the restricted version, and it is simpler to implement the overparametrized version. from a neuroscientific point of view, it is interesting to think of the softmax as a way to create a form of competition between the units that participate in it : the softmax outputs always sum to 1 so an increase in the value of one unit necessarily corresponds to a decrease in the value of others. this is analogous to the lateral inhibition that is believed to exist between nearby neurons in the cortex. at the extreme ( when the [UNK] between the maximal ai and the others is large in magnitude ) it becomes a form of winner - take - all ( one of the outputs is nearly 1 and the others are nearly 0 ). the name “ softmax ” can be somewhat confusing. the function is more closely related to the arg max function than the max function. the term “ soft ” derives from the fact that the softmax function
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 202
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
and the others are nearly 0 ). the name “ softmax ” can be somewhat confusing. the function is more closely related to the arg max function than the max function. the term “ soft ” derives from the fact that the softmax function is continuous and [UNK]. the arg max function, with its result represented as a one - hot vector, is not continuous or [UNK]. the softmax function thus provides a “ softened ” version of the arg max. the corresponding soft version of the maximum function is softmax ( z ) z. it would perhaps be better to call the softmax function “ softargmax, ” but the current name is an entrenched convention. 6. 2. 2. 4 other output types the linear, sigmoid, and softmax output units described above are the most common. neural networks can generalize to almost any kind of output layer that we wish. the principle of maximum likelihood provides a guide for how to design 187
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 202
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks a good cost function for nearly any kind of output layer. in general, if we define a conditional distribution p ( y x | ; θ ), the principle of maximum likelihood suggests we use as our cost function. − | log ( p y x θ ; ) in general, we can think of the neural network as representing a function f ( x ; θ ). the outputs of this function are not direct predictions of the value y. instead, f ( x ; θ ) = ω provides the parameters for a distribution over y. our loss function can then be interpreted as. −log ( ; ( ) ) p y ω x for example, we may wish to learn the variance of a conditional gaussian for y, given x. in the simple case, where the variance σ 2 is a constant, there is a closed form expression because the maximum likelihood estimator of variance is simply the empirical mean of the squared [UNK] between observationsy and their expected value. a computationally more expensive approach that does not require writing special - case code is to simply include the variance as one of the properties of the distribution p ( y | x ) that is controlled by ω = f ( x ; θ ). the negative log
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 203
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
computationally more expensive approach that does not require writing special - case code is to simply include the variance as one of the properties of the distribution p ( y | x ) that is controlled by ω = f ( x ; θ ). the negative log - likelihood −log p ( y ; ω ( x ) ) will then provide a cost function with the appropriate terms necessary to make our optimization procedure incrementally learn the variance. in the simple case where the standard deviation does not depend on the input, we can make a new parameter in the network that is copied directly into ω. this new parameter might be σ itself or could be a parameter v representing σ2 or it could be a parameter β representing 1 σ 2, depending on how we choose to parametrize the distribution. we may wish our model to predict a [UNK] amount of variance in y for [UNK] values of x. this is called a heteroscedastic model. in the heteroscedastic case, we simply make the specification of the variance be one of the values output by f ( x ; θ ). a typical way to do this is to formulate the gaussian distribution using precision, rather than variance, as described in equation. 3. 22 in the multivariate
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 203
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
variance be one of the values output by f ( x ; θ ). a typical way to do this is to formulate the gaussian distribution using precision, rather than variance, as described in equation. 3. 22 in the multivariate case it is most common to use a diagonal precision matrix diag ( 6. 34 ) ( ) β. this formulation works well with gradient descent because the formula for the log - likelihood of the gaussian distribution parametrized by β involves only mul - tiplication by βi and addition of log βi. the gradient of multiplication, addition, and logarithm operations is well - behaved. by comparison, if we parametrized the output in terms of variance, we would need to use division. the division function becomes arbitrarily steep near zero. while large gradients can help learning, arbitrarily large gradients usually result in instability. if we parametrized the output in terms of standard deviation, the log - likelihood would still involve division, and would also involve squaring. the gradient through the squaring operation can vanish near zero, making it [UNK] to learn parameters that are squared. 188
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 203
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks regardless of whether we use standard deviation, variance, or precision, we must ensure that the covariance matrix of the gaussian is positive definite. because the eigenvalues of the precision matrix are the reciprocals of the eigenvalues of the covariance matrix, this is equivalent to ensuring that the precision matrix is positive definite. if we use a diagonal matrix, or a scalar times the diagonal matrix, then the only condition we need to enforce on the output of the model is positivity. if we suppose that a is the raw activation of the model used to determine the diagonal precision, we can use the softplus function to obtain a positive precision vector : β = ζ ( a ). this same strategy applies equally if using variance or standard deviation rather than precision or if using a scalar times identity rather than diagonal matrix. it is rare to learn a covariance or precision matrix with richer structure than diagonal. if the covariance is full and conditional, then a parametrization must be chosen that guarantees positive - definiteness of the predicted covariance matrix. this can be achieved by writing σ ( ) = ( ) x b x
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 204
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
if the covariance is full and conditional, then a parametrization must be chosen that guarantees positive - definiteness of the predicted covariance matrix. this can be achieved by writing σ ( ) = ( ) x b x b ( ) x, whereb is an unconstrained square matrix. one practical issue if the matrix is full rank is that computing the likelihood is expensive, with a d d × matrix requiring o ( d3 ) computation for the determinant and inverse of σ ( x ) ( or equivalently, and more commonly done, its eigendecomposition or that of ). b x ( ) we often want to perform multimodal regression, that is, to predict real values that come from a conditional distribution p ( y x | ) that can have several [UNK] peaks in y space for the same value of x. in this case, a gaussian mixture is a natural representation for the output (, ;, ). jacobs et al. 1991 bishop 1994 neural networks with gaussian mixtures as their output are often called mixture density networks. a gaussian mixture output with n components is defined by the conditional probability distribution p ( ) = y x | n i = 1 p i
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 204
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
1994 neural networks with gaussian mixtures as their output are often called mixture density networks. a gaussian mixture output with n components is defined by the conditional probability distribution p ( ) = y x | n i = 1 p i ( = c | n x ) ( ; y µ ( ) i ( ) x, σ ( ) i ( ) ) x. ( 6. 35 ) the neural network must have three outputs : a vector defining p ( c = i | x ), a matrix providing µ ( ) i ( x ) for all i, and a tensor providing σ ( ) i ( x ) for all i. these outputs must satisfy [UNK] constraints : 1. mixture components p ( c = i | x ) : these form a multinoulli distribution over the n [UNK] components associated with latent variable1 c, and can 1we consider c to be latent because we do not observe it in the data : given input x and target y, it is not possible to know with certainty which gaussian component was responsible for y, but we can imagine that y was generated by picking one of them, and make that unobserved choice a random variable. 189
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 204
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks typically be obtained by a softmax over an n - dimensional vector, to guarantee that these outputs are positive and sum to 1. 2. means µ ( ) i ( x ) : these indicate the center or mean associated with the i - th gaussian component, and are unconstrained ( typically with no nonlinearity at all for these output units ). if y is a d - vector, then the network must output an n d × matrix containing all n of these d - dimensional vectors. learning these means with maximum likelihood is slightly more complicated than learning the means of a distribution with only one output mode. we only want to update the mean for the component that actually produced the observation. in practice, we do not know which component produced each observation. the expression for the negative log - likelihood naturally weights each example ’ s contribution to the loss for each component by the probability that the component produced the example. 3. covariances σ ( ) i ( x ) : these specify the covariance matrix for each component i. as when learning a single gaussian component, we typically use a diagonal matrix to avoid needing to compute determinants. as with learning the means of the mixture, maximum likelihood is
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 205
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
: these specify the covariance matrix for each component i. as when learning a single gaussian component, we typically use a diagonal matrix to avoid needing to compute determinants. as with learning the means of the mixture, maximum likelihood is complicated by needing to assign partial responsibility for each point to each mixture component. gradient descent will automatically follow the correct process if given the correct specification of the negative log - likelihood under the mixture model. it has been reported that gradient - based optimization of conditional gaussian mixtures ( on the output of neural networks ) can be unreliable, in part because one gets divisions ( by the variance ) which can be numerically unstable ( when some variance gets to be small for a particular example, yielding very large gradients ). one solution is to clip gradients ( see section ) while another is to scale 10. 11. 1 the gradients heuristically (, ). murray and larochelle 2014 gaussian mixture outputs are particularly [UNK] in generative models of speech ( schuster 1999, ) or movements of physical objects ( graves 2013, ). the mixture density strategy gives a way for the network to represent multiple output modes and to control the variance of its output, which is crucial for obtaining a
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 205
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
##tive models of speech ( schuster 1999, ) or movements of physical objects ( graves 2013, ). the mixture density strategy gives a way for the network to represent multiple output modes and to control the variance of its output, which is crucial for obtaining a high degree of quality in these real - valued domains. an example of a mixture density network is shown in figure. 6. 4 in general, we may wish to continue to model larger vectors y containing more variables, and to impose richer and richer structures on these output variables. for example, we may wish for our neural network to output a sequence of characters that forms a sentence. in these cases, we may continue to use the principle of maximum likelihood applied to our model p ( y ; ω ( x ) ), but the model we use 190
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 205
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks x y figure 6. 4 : samples drawn from a neural network with a mixture density output layer. the input x is sampled from a uniform distribution and the output y is sampled from pmodel ( y x | ). the neural network is able to learn nonlinear mappings from the input to the parameters of the output distribution. these parameters include the probabilities governing which of three mixture components will generate the output as well as the parameters for each mixture component. each mixture component is gaussian with predicted mean and variance. all of these aspects of the output distribution are able to vary with respect to the input, and to do so in nonlinear ways. x to describe y becomes complex enough to be beyond the scope of this chapter. chapter describes how to use recurrent neural networks to define such models 10 over sequences, and part describes advanced techniques for modeling arbitrary iii probability distributions. 6. 3 hidden units so far we have focused our discussion on design choices for neural networks that are common to most parametric machine learning models trained with gradient - based optimization. now we turn to an issue that is unique to feedforward neural networks : how to choose the type of hidden unit to use in the hidden layers of the model.
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 206
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
are common to most parametric machine learning models trained with gradient - based optimization. now we turn to an issue that is unique to feedforward neural networks : how to choose the type of hidden unit to use in the hidden layers of the model. the design of hidden units is an extremely active area of research and does not yet have many definitive guiding theoretical principles. rectified linear units are an excellent default choice of hidden unit. many other types of hidden units are available. it can be [UNK] to determine when to use which kind ( though rectified linear units are usually an acceptable choice ). we 191
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 206
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks describe here some of the basic intuitions motivating each type of hidden units. these intuitions can help decide when to try out each of these units. it is usually impossible to predict in advance which will work best. the design process consists of trial and error, intuiting that a kind of hidden unit may work well, and then training a network with that kind of hidden unit and evaluating its performance on a validation set. some of the hidden units included in this list are not actually [UNK] at all input points. for example, the rectified linear function g ( z ) = max { 0, z } is not [UNK] at z = 0. this may seem like it invalidates g for use with a gradient - based learning algorithm. in practice, gradient descent still performs well enough for these models to be used for machine learning tasks. this is in part because neural network training algorithms do not usually arrive at a local minimum of the cost function, but instead merely reduce its value significantly, as shown in figure. these ideas will be described further in chapter. because we do not 4. 3 8 expect training to actually reach a point where the gradient is 0, it is acceptable for the
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 207
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
its value significantly, as shown in figure. these ideas will be described further in chapter. because we do not 4. 3 8 expect training to actually reach a point where the gradient is 0, it is acceptable for the minima of the cost function to correspond to points with undefined gradient. hidden units that are not [UNK] are usually non - [UNK] at only a small number of points. in general, a function g ( z ) has a left derivative defined by the slope of the function immediately to the left of z and a right derivative defined by the slope of the function immediately to the right of z. a function is [UNK] at z only if both the left derivative and the right derivative are defined and equal to each other. the functions used in the context of neural networks usually have defined left derivatives and defined right derivatives. in the case of g ( z ) = max { 0, z }, the left derivative at z = 0 0 is and the right derivative is. software implementations of neural network training usually return one of 1 the one - sided derivatives rather than reporting that the derivative is undefined or raising an error. this may be heuristically justifi
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 207
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
0 is and the right derivative is. software implementations of neural network training usually return one of 1 the one - sided derivatives rather than reporting that the derivative is undefined or raising an error. this may be heuristically justified by observing that gradient - based optimization on a digital computer is subject to numerical error anyway. when a function is asked to evaluate g ( 0 ), it is very unlikely that the underlying value truly was. instead, it was likely to be some small value 0 that was rounded to. in some contexts, more theoretically pleasing justifications are available, but 0 these usually do not apply to neural network training. the important point is that in practice one can safely disregard the non - [UNK] of the hidden unit activation functions described below. unless indicated otherwise, most hidden units can be described as accepting a vector of inputs x, computing an [UNK] transformation z = w x + b, and then applying an element - wise nonlinear function g ( z ). most hidden units are distinguished from each other only by the choice of the form of the activation function. g ( ) z 192
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 207
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 6. 3. 1 rectified linear units and their generalizations rectified linear units use the activation function. g z, z ( ) = max 0 { } rectified linear units are easy to optimize because they are so similar to linear units. the only [UNK] between a linear unit and a rectified linear unit is that a rectified linear unit outputs zero across half its domain. this makes the derivatives through a rectified linear unit remain large whenever the unit is active. the gradients are not only large but also consistent. the second derivative of the rectifying operation is almost everywhere, and the derivative of the rectifying 0 operation is everywhere that the unit is active. this means that the gradient 1 direction is far more useful for learning than it would be with activation functions that introduce second - order [UNK]. rectified linear units are typically used on top of an [UNK] transformation : h w = ( g x b + ). ( 6. 36 ) when initializing the parameters of the [UNK] transformation, it can be a good practice to set all elements of b to a small, positive value, such as 0. 1. this makes it very
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 208
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
g x b + ). ( 6. 36 ) when initializing the parameters of the [UNK] transformation, it can be a good practice to set all elements of b to a small, positive value, such as 0. 1. this makes it very likely that the rectified linear units will be initially active for most inputs in the training set and allow the derivatives to pass through. several generalizations of rectified linear units exist. most of these general - izations perform comparably to rectified linear units and occasionally perform better. one drawback to rectified linear units is that they cannot learn via gradient - based methods on examples for which their activation is zero. a variety of generalizations of rectified linear units guarantee that they receive gradient every - where. three generalizations of rectified linear units are based on using a non - zero slope αi when zi < 0 : hi = g ( z α, ) i = max ( 0, zi ) + αi min ( 0, zi ). absolute value rectification fixes αi = −1 to obtain g ( z ) = | | z. it is used for object recognition from images (, ), where
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 208
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
##i ) + αi min ( 0, zi ). absolute value rectification fixes αi = −1 to obtain g ( z ) = | | z. it is used for object recognition from images (, ), where it makes sense to seek features that are jarrett et al. 2009 invariant under a polarity reversal of the input illumination. other generalizations of rectified linear units are more broadly applicable. a leaky relu (, maas et al. 2013 ) fixes αi to a small value like 0. 01 while a parametric relu or prelu treats αi as a learnable parameter (, ). he et al. 2015 maxout units (, ) generalize rectified linear units goodfellow et al. 2013a further. instead of applying an element - wise function g ( z ), maxout units divide z into groups of k values. each maxout unit then outputs the maximum element of 193
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 208
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks one of these groups : g ( ) z i = max j∈g ( ) i zj ( 6. 37 ) where g ( ) i is the set of indices into the inputs for group i, { ( i −1 ) k + 1,..., ik }. this provides a way of learning a piecewise linear function that responds to multiple directions in the input space. x a maxout unit can learn a piecewise linear, convex function with up to k pieces. maxout units can thus be seen as learning the activation function itself rather than just the relationship between units. with large enough k, a maxout unit can learn to approximate any convex function with arbitrary fidelity. in particular, a maxout layer with two pieces can learn to implement the same function of the input x as a traditional layer using the rectified linear activation function, absolute value rectification function, or the leaky or parametric relu, or can learn to implement a totally [UNK] function altogether. the maxout layer will of course be parametrized [UNK] from any of these other layer types, so the learning dynamics will be [UNK] even in the cases where maxout learns to implement the same function of
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 209
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
learn to implement a totally [UNK] function altogether. the maxout layer will of course be parametrized [UNK] from any of these other layer types, so the learning dynamics will be [UNK] even in the cases where maxout learns to implement the same function of as one of the other layer types. x each maxout unit is now parametrized by k weight vectors instead of just one, so maxout units typically need more regularization than rectified linear units. they can work well without regularization if the training set is large and the number of pieces per unit is kept low (, ). cai et al. 2013 maxout units have a few other benefits. in some cases, one can gain some sta - tistical and computational advantages by requiring fewer parameters. specifically, if the features captured by n [UNK] linear filters can be summarized without losing information by taking the max over each group of k features, then the next layer can get by with times fewer weights. k because each unit is driven by multiple filters, maxout units have some redun - dancy that helps them to resist a phenomenon called catastrophic forgetting in which neural networks forget how to perform tasks that they were trained on in the past (,
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 209
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
because each unit is driven by multiple filters, maxout units have some redun - dancy that helps them to resist a phenomenon called catastrophic forgetting in which neural networks forget how to perform tasks that they were trained on in the past (, ). goodfellow et al. 2014a rectified linear units and all of these generalizations of them are based on the principle that models are easier to optimize if their behavior is closer to linear. this same general principle of using linear behavior to obtain easier optimization also applies in other contexts besides deep linear networks. recurrent networks can learn from sequences and produce a sequence of states and outputs. when training them, one needs to propagate information through several time steps, which is much easier when some linear computations ( with some directional derivatives being of magnitude near 1 ) are involved. one of the best - performing recurrent network 194
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 209
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks architectures, the lstm, propagates information through time via summation — a particular straightforward kind of such linear activation. this is discussed further in section. 10. 10 6. 3. 2 logistic sigmoid and hyperbolic tangent prior to the introduction of rectified linear units, most neural networks used the logistic sigmoid activation function g z σ z ( ) = ( ) ( 6. 38 ) or the hyperbolic tangent activation function g z z. ( ) = tanh ( ) ( 6. 39 ) these activation functions are closely related because. tanh ( ) = 2 ( 2 ) 1 z σ z − we have already seen sigmoid units as output units, used to predict the probability that a binary variable is. unlike piecewise linear units, sigmoidal 1 units saturate across most of their domain — they saturate to a high value when z is very positive, saturate to a low value when z is very negative, and are only strongly sensitive to their input when z is near 0. the widespread saturation of sigmoidal units can make gradient - based learning very [UNK]. for this reason, their use as hidden units in
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 210
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
value when z is very negative, and are only strongly sensitive to their input when z is near 0. the widespread saturation of sigmoidal units can make gradient - based learning very [UNK]. for this reason, their use as hidden units in feedforward networks is now discouraged. their use as output units is compatible with the use of gradient - based learning when an appropriate cost function can undo the saturation of the sigmoid in the output layer. when a sigmoidal activation function must be used, the hyperbolic tangent activation function typically performs better than the logistic sigmoid. it resembles the identity function more closely, in the sense that tanh ( 0 ) = 0 while σ ( 0 ) = 1 2. because tanh is similar to the identity function near, training a deep neural 0 network [UNK] = wtanh ( u tanh ( v x ) ) resembles training a linear model [UNK] = wuv x so long as the activations of the network can be kept small. this makes training the network easier. tanh sigmoidal activation functions are more common in settings other than feed - forward networks. recurrent networks, many probabilistic models, and some autoencoders have additional requirements that rule out the use
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 210
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
training the network easier. tanh sigmoidal activation functions are more common in settings other than feed - forward networks. recurrent networks, many probabilistic models, and some autoencoders have additional requirements that rule out the use of piecewise linear activation functions and make sigmoidal units more appealing despite the drawbacks of saturation. 195
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 210
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 6. 3. 3 other hidden units many other types of hidden units are possible, but are used less frequently. in general, a wide variety of [UNK] functions perform perfectly well. many unpublished activation functions perform just as well as the popular ones. to provide a concrete example, the authors tested a feedforward network using h = cos ( wx + b ) on the mnist dataset and obtained an error rate of less than 1 %, which is competitive with results obtained using more conventional activation functions. during research and development of new techniques, it is common to test many [UNK] activation functions and find that several variations on standard practice perform comparably. this means that usually new hidden unit types are published only if they are clearly demonstrated to provide a significant improvement. new hidden unit types that perform roughly comparably to known types are so common as to be uninteresting. it would be impractical to list all of the hidden unit types that have appeared in the literature. we highlight a few especially useful and distinctive ones. one possibility is to not have an activation g ( z ) at all. one can also think of this as using the identity function as the activation function. we have
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 211
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
that have appeared in the literature. we highlight a few especially useful and distinctive ones. one possibility is to not have an activation g ( z ) at all. one can also think of this as using the identity function as the activation function. we have already seen that a linear unit can be useful as the output of a neural network. it may also be used as a hidden unit. if every layer of the neural network consists of only linear transformations, then the network as a whole will be linear. however, it is acceptable for some layers of the neural network to be purely linear. consider a neural network layer with n inputs and p outputs, h = g ( w x + b ). we may replace this with two layers, with one layer using weight matrix u and the other using weight matrix v. if the first layer has no activation function, then we have essentially factored the weight matrix of the original layer based on w. the factored approach is to compute h = g ( v ux + b ). if u produces q outputs, then u and v together contain only ( n + p ) q parameters, while w contains np parameters. for small q, this can be a considerable saving in parameters. it comes at the cost of constraining
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 211
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. if u produces q outputs, then u and v together contain only ( n + p ) q parameters, while w contains np parameters. for small q, this can be a considerable saving in parameters. it comes at the cost of constraining the linear transformation to be low - rank, but these low - rank relationships are often [UNK]. linear hidden units thus [UNK] an [UNK] way of reducing the number of parameters in a network. softmax units are another kind of unit that is usually used as an output ( as described in section ) but may sometimes be used as a hidden unit. softmax 6. 2. 2. 3 units naturally represent a probability distribution over a discrete variable with k possible values, so they may be used as a kind of switch. these kinds of hidden units are usually only used in more advanced architectures that explicitly learn to manipulate memory, described in section. 10. 12 196
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 211
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks a few other reasonably common hidden unit types include : • radial basis function or rbf unit : hi = exp −1 σ 2 i | | w :, i − | | x 2. this function becomes more active as x approaches a template w :, i. because it saturates to for most, it can be [UNK] to optimize. 0 x • softplus : g ( a ) = ζ ( a ) = log ( 1 + ea ). this is a smooth version of the rectifier, introduced by ( ) for function approximation and by dugas et al. 2001 nair and hinton 2010 ( ) for the conditional distributions of undirected probabilistic models. ( ) compared the softplus and rectifier and found glorot et al. 2011a better results with the latter. the use of the softplus is generally discouraged. the softplus demonstrates that the performance of hidden unit types can be very counterintuitive — one might expect it to have an advantage over the rectifier due to being [UNK] everywhere or due to saturating less completely, but empirically it does not. • hard tanh : this is shaped similarly
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 212
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
very counterintuitive — one might expect it to have an advantage over the rectifier due to being [UNK] everywhere or due to saturating less completely, but empirically it does not. • hard tanh : this is shaped similarly to the tanh and the rectifier but unlike the latter, it is bounded, g ( a ) = max ( −1, min ( 1, a ) ). it was introduced by ( ). collobert 2004 hidden unit design remains an active area of research and many useful hidden unit types remain to be discovered. 6. 4 architecture design another key design consideration for neural networks is determining the architecture. the word architecture refers to the overall structure of the network : how many units it should have and how these units should be connected to each other. most neural networks are organized into groups of units called layers. most neural network architectures arrange these layers in a chain structure, with each layer being a function of the layer that preceded it. in this structure, the first layer is given by h ( 1 ) = g ( 1 ) w ( 1 ) x b + ( 1 ), ( 6. 40 ) the second layer is given by h ( 2 ) = g ( 2 ) w ( 2
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 212
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
the first layer is given by h ( 1 ) = g ( 1 ) w ( 1 ) x b + ( 1 ), ( 6. 40 ) the second layer is given by h ( 2 ) = g ( 2 ) w ( 2 ) h ( 1 ) + b ( 2 ), ( 6. 41 ) and so on. 197
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 212
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks in these chain - based architectures, the main architectural considerations are to choose the depth of the network and the width of each layer. as we will see, a network with even one hidden layer is [UNK] to fit the training set. deeper networks often are able to use far fewer units per layer and far fewer parameters and often generalize to the test set, but are also often harder to optimize. the ideal network architecture for a task must be found via experimentation guided by monitoring the validation set error. 6. 4. 1 universal approximation properties and depth a linear model, mapping from features to outputs via matrix multiplication, can by definition represent only linear functions. it has the advantage of being easy to train because many loss functions result in convex optimization problems when applied to linear models. unfortunately, we often want to learn nonlinear functions. at first glance, we might presume that learning a nonlinear function requires designing a specialized model family for the kind of nonlinearity we want to learn. fortunately, feedforward networks with hidden layers provide a universal approxi - mation framework. specifically, the universal approximation theorem ( hornik et al., ;, ) states that a feedforward network
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 213
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
want to learn. fortunately, feedforward networks with hidden layers provide a universal approxi - mation framework. specifically, the universal approximation theorem ( hornik et al., ;, ) states that a feedforward network with a linear output 1989 cybenko 1989 layer and at least one hidden layer with any “ squashing ” activation function ( such as the logistic sigmoid activation function ) can approximate any borel measurable function from one finite - dimensional space to another with any desired non - zero amount of error, provided that the network is given enough hidden units. the derivatives of the feedforward network can also approximate the derivatives of the function arbitrarily well (, ). the concept of borel measurability hornik et al. 1990 is beyond the scope of this book ; for our purposes it [UNK] to say that any continuous function on a closed and bounded subset of rn is borel measurable and therefore may be approximated by a neural network. a neural network may also approximate any function mapping from any finite dimensional discrete space to another. while the original theorems were first stated in terms of units with activation functions that saturate both for very negative and for very positive arguments
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 213
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. a neural network may also approximate any function mapping from any finite dimensional discrete space to another. while the original theorems were first stated in terms of units with activation functions that saturate both for very negative and for very positive arguments, universal approximation theorems have also been proved for a wider class of activation functions, which includes the now commonly used rectified linear unit (, ). leshno et al. 1993 the universal approximation theorem means that regardless of what function we are trying to learn, we know that a large mlp will be able to represent this function. however, we are not guaranteed that the training algorithm will be able to learn that function. even if the mlp is able to represent the function, learning can fail for two [UNK] reasons. first, the optimization algorithm used for training 198
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 213
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks may not be able to find the value of the parameters that corresponds to the desired function. second, the training algorithm might choose the wrong function due to overfitting. recall from section that the “ no free lunch ” theorem shows that 5. 2. 1 there is no universally superior machine learning algorithm. feedforward networks provide a universal system for representing functions, in the sense that, given a function, there exists a feedforward network that approximates the function. there is no universal procedure for examining a training set of specific examples and choosing a function that will generalize to points not in the training set. the universal approximation theorem says that there exists a network large enough to achieve any degree of accuracy we desire, but the theorem does not say how large this network will be. ( ) provides some bounds on the barron 1993 size of a single - layer network needed to approximate a broad class of functions. unfortunately, in the worse case, an exponential number of hidden units ( possibly with one hidden unit corresponding to each input configuration that needs to be distinguished ) may be required. this is easiest to see in the binary case : the number of possible binary functions on vectors v ∈ { 0, 1
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 214
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
hidden units ( possibly with one hidden unit corresponding to each input configuration that needs to be distinguished ) may be required. this is easiest to see in the binary case : the number of possible binary functions on vectors v ∈ { 0, 1 } n is 22 n and selecting one such function requires 2n bits, which will in general require o ( 2n ) degrees of freedom. in summary, a feedforward network with a single layer is [UNK] to represent any function, but the layer may be infeasibly large and may fail to learn and generalize correctly. in many circumstances, using deeper models can reduce the number of units required to represent the desired function and can reduce the amount of generalization error. there exist families of functions which can be approximated [UNK] by an architecture with depth greater than some valued, but which require a much larger model if depth is restricted to be less than or equal to d. in many cases, the number of hidden units required by the shallow model is exponential in n. such results were first proved for models that do not resemble the continuous, [UNK] neural networks used for machine learning, but have since been extended to these models. the first results were for circuits of logic gates (, ). later hastad
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 214
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. such results were first proved for models that do not resemble the continuous, [UNK] neural networks used for machine learning, but have since been extended to these models. the first results were for circuits of logic gates (, ). later hastad 1986 work extended these results to linear threshold units with non - negative weights (, ;, ), and then to networks with hastad and goldmann 1991 hajnal et al. 1993 continuous - valued activations (, ;, ). many modern maass 1992 maass et al. 1994 neural networks use rectified linear units. ( ) demonstrated leshno et al. 1993 that shallow networks with a broad family of non - polynomial activation functions, including rectified linear units, have universal approximation properties, but these results do not address the questions of depth or [UNK] — they specify only that a [UNK] wide rectifier network could represent any function. montufar et al. 199
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 214
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks ( ) showed that functions representable with a deep rectifier net can require 2014 an exponential number of hidden units with a shallow ( one hidden layer ) network. more precisely, they showed that piecewise linear networks ( which can be obtained from rectifier nonlinearities or maxout units ) can represent functions with a number of regions that is exponential in the depth of the network. figure illustrates how 6. 5 a network with absolute value rectification creates mirror images of the function computed on top of some hidden unit, with respect to the input of that hidden unit. each hidden unit specifies where to fold the input space in order to create mirror responses ( on both sides of the absolute value nonlinearity ). by composing these folding operations, we obtain an exponentially large number of piecewise linear regions which can capture all kinds of regular ( e. g., repeating ) patterns. figure 6. 5 : an intuitive, geometric explanation of the exponential advantage of deeper rectifier networks formally by ( ). montufar et al. 2014 ( left ) an absolute value rectification unit has the same output for every pair of mirror points in its input. the mirror axis of symmetry is
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 215
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
of deeper rectifier networks formally by ( ). montufar et al. 2014 ( left ) an absolute value rectification unit has the same output for every pair of mirror points in its input. the mirror axis of symmetry is given by the hyperplane defined by the weights and bias of the unit. a function computed on top of that unit ( the green decision surface ) will be a mirror image of a simpler pattern across that axis of symmetry. the function can be obtained ( center ) by folding the space around the axis of symmetry. another repeating pattern can ( right ) be folded on top of the first ( by another downstream unit ) to obtain another symmetry ( which is now repeated four times, with two hidden layers ). figure reproduced with permission from ( ). montufar et al. 2014 more precisely, the main theorem in ( ) states that the montufar et al. 2014 number of linear regions carved out by a deep rectifier network with d inputs, depth, and units per hidden layer, is l n o n d d l ( −1 ) nd, ( 6. 42 ) i. e., exponential in the depth. in the case of maxout networks with filters per l
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 215
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
, and units per hidden layer, is l n o n d d l ( −1 ) nd, ( 6. 42 ) i. e., exponential in the depth. in the case of maxout networks with filters per l k unit, the number of linear regions is o k ( 1 ) + l− d. ( 6. 43 ) 200
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 215
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks of course, there is no guarantee that the kinds of functions we want to learn in applications of machine learning ( and in particular for ai ) share such a property. we may also want to choose a deep model for statistical reasons. any time we choose a specific machine learning algorithm, we are implicitly stating some set of prior beliefs we have about what kind of function the algorithm should learn. choosing a deep model encodes a very general belief that the function we want to learn should involve composition of several simpler functions. this can be interpreted from a representation learning point of view as saying that we believe the learning problem consists of discovering a set of underlying factors of variation that can in turn be described in terms of other, simpler underlying factors of variation. alternately, we can interpret the use of a deep architecture as expressing a belief that the function we want to learn is a computer program consisting of multiple steps, where each step makes use of the previous step ’ s output. these intermediate outputs are not necessarily factors of variation, but can instead be analogous to counters or pointers that the network uses to organize its internal processing. empirically, greater depth does seem to result in better generalization for a wide variety of tasks (, ;
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 216
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
outputs are not necessarily factors of variation, but can instead be analogous to counters or pointers that the network uses to organize its internal processing. empirically, greater depth does seem to result in better generalization for a wide variety of tasks (, ;, ;, ; bengio et al. 2007 erhan et al. 2009 bengio 2009 mesnil 2011 ciresan 2012 krizhevsky 2012 sermanet et al., ; et al., ; et al., ; et al., 2013 farabet 2013 couprie 2013 kahou 2013 goodfellow ; et al., ; et al., ; et al., ; et al. et al., ; 2014d szegedy, ). see figure and figure for examples of 2014a 6. 6 6. 7 some of these empirical results. this suggests that using deep architectures does indeed express a useful prior over the space of functions the model learns. 6. 4. 2 other architectural considerations so far we have described neural networks as being simple chains of layers, with the main considerations being the depth of the network and the width of each layer. in practice, neural networks show considerably more diversity. many neural network architectures have been
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 216
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
architectural considerations so far we have described neural networks as being simple chains of layers, with the main considerations being the depth of the network and the width of each layer. in practice, neural networks show considerably more diversity. many neural network architectures have been developed for specific tasks. specialized architectures for computer vision called convolutional networks are described in chapter. feedforward networks may also be generalized to the 9 recurrent neural networks for sequence processing, described in chapter, which 10 have their own architectural considerations. in general, the layers need not be connected in a chain, even though this is the most common practice. many architectures build a main chain but then add extra architectural features to it, such as skip connections going from layer i to layer i + 2 or higher. these skip connections make it easier for the gradient to flow from output layers to layers nearer the input. 201
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 216
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 3 4 5 6 7 8 9 10 11 92 0. 92 5. 93 0. 93 5. 94 0. 94 5. 95 0. 95 5. 96 0. 96 5. test accuracy ( percent ) figure 6. 6 : empirical results showing that deeper networks generalize better when used to transcribe multi - digit numbers from photographs of addresses. data from goodfellow et al. ( ). the test set accuracy consistently increases with increasing depth. see 2014d figure for a control experiment demonstrating that other increases to the model size 6. 7 do not yield the same [UNK]. another key consideration of architecture design is exactly how to connect a pair of layers to each other. in the default neural network layer described by a linear transformation via a matrix w, every input unit is connected to every output unit. many specialized networks in the chapters ahead have fewer connections, so that each unit in the input layer is connected to only a small subset of units in the output layer. these strategies for reducing the number of connections reduce the number of parameters and the amount of computation required to evaluate the network, but are often highly problem - dependent. for example, convolutional networks, described in chapter, use specialized
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 217
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
layer. these strategies for reducing the number of connections reduce the number of parameters and the amount of computation required to evaluate the network, but are often highly problem - dependent. for example, convolutional networks, described in chapter, use specialized patterns of sparse connections 9 that are very [UNK] for computer vision problems. in this chapter, it is [UNK] to give much more specific advice concerning the architecture of a generic neural network. subsequent chapters develop the particular architectural strategies that have been found to work well for [UNK] application domains. 202
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 217
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 0 0 0 2 0 4 0 6 0 8 1 0...... number of parameters ×108 91 92 93 94 95 96 97 test accuracy ( percent ) 3, convolutional 3, fully connected 11, convolutional figure 6. 7 : deeper models tend to perform better. this is not merely because the model is larger. this experiment from goodfellow 2014d et al. ( ) shows that increasing the number of parameters in layers of convolutional networks without increasing their depth is not nearly as [UNK] at increasing test set performance. the legend indicates the depth of network used to make each curve and whether the curve represents variation in the size of the convolutional or the fully connected layers. we observe that shallow models in this context overfit at around 20 million parameters while deep ones can benefit from having over 60 million. this suggests that using a deep model expresses a useful preference over the space of functions the model can learn. specifically, it expresses a belief that the function should consist of many simpler functions composed together. this could result either in learning a representation that is composed in turn of simpler representations ( e. g.
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 218
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
of functions the model can learn. specifically, it expresses a belief that the function should consist of many simpler functions composed together. this could result either in learning a representation that is composed in turn of simpler representations ( e. g., corners defined in terms of edges ) or in learning a program with sequentially dependent steps ( e. g., first locate a set of objects, then segment them from each other, then recognize them ). 203
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 218
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 6. 5 back - propagation and other [UNK] algo - rithms when we use a feedforward neural network to accept an input x and produce an output [UNK], information flows forward through the network. the inputs x provide the initial information that then propagates up to the hidden units at each layer and finally produces [UNK]. this is called forward propagation. during training, forward propagation can continue onward until it produces a scalar cost j ( θ ). the back - propagation algorithm (, ), often simply called rumelhart et al. 1986a backprop, allows the information from the cost to then flow backwards through the network, in order to compute the gradient. computing an analytical expression for the gradient is straightforward, but numerically evaluating such an expression can be computationally expensive. the back - propagation algorithm does so using a simple and inexpensive procedure. the term back - propagation is often misunderstood as meaning the whole learning algorithm for multi - layer neural networks. actually, back - propagation refers only to the method for computing the gradient, while another algorithm, such as stochastic gradient descent, is used to perform learning using this gradient. furthermore, back - propagation is often misunderstood as being specifi
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 219
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. actually, back - propagation refers only to the method for computing the gradient, while another algorithm, such as stochastic gradient descent, is used to perform learning using this gradient. furthermore, back - propagation is often misunderstood as being specific to multi - layer neural networks, but in principle it can compute derivatives of any function ( for some functions, the correct response is to report that the derivative of the function is undefined ). specifically, we will describe how to compute the gradient ∇xf ( x y, ) for an arbitrary function f, wherex is a set of variables whose derivatives are desired, and y is an additional set of variables that are inputs to the function but whose derivatives are not required. in learning algorithms, the gradient we most often require is the gradient of the cost function with respect to the parameters, ∇θj ( θ ). many machine learning tasks involve computing other derivatives, either as part of the learning process, or to analyze the learned model. the back - propagation algorithm can be applied to these tasks as well, and is not restricted to computing the gradient of the cost function with respect to the parameters. the idea of computing derivatives by propagating information through a network is very general,
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 219
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. the back - propagation algorithm can be applied to these tasks as well, and is not restricted to computing the gradient of the cost function with respect to the parameters. the idea of computing derivatives by propagating information through a network is very general, and can be used to compute values such as the jacobian of a function f with multiple outputs. we restrict our description here to the most commonly used case where has a single output. f 204
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 219
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks 6. 5. 1 computational graphs so far we have discussed neural networks with a relatively informal graph language. to describe the back - propagation algorithm more precisely, it is helpful to have a more precise language. computational graph many ways of formalizing computation as graphs are possible. here, we use each node in the graph to indicate a variable. the variable may be a scalar, vector, matrix, tensor, or even a variable of another type. to formalize our graphs, we also need to introduce the idea of an operation. an operation is a simple function of one or more variables. our graph language is accompanied by a set of allowable operations. functions more complicated than the operations in this set may be described by composing many operations together. without loss of generality, we define an operation to return only a single output variable. this does not lose generality because the output variable can have multiple entries, such as a vector. software implementations of back - propagation usually support operations with multiple outputs, but we avoid this case in our description because it introduces many extra details that are not important to conceptual understanding. if a variable y is computed by applying an operation to a variable x, then we draw a directed edge from x
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 220
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
operations with multiple outputs, but we avoid this case in our description because it introduces many extra details that are not important to conceptual understanding. if a variable y is computed by applying an operation to a variable x, then we draw a directed edge from x to y. we sometimes annotate the output node with the name of the operation applied, and other times omit this label when the operation is clear from context. examples of computational graphs are shown in figure. 6. 8 6. 5. 2 chain rule of calculus the chain rule of calculus ( not to be confused with the chain rule of probability ) is used to compute the derivatives of functions formed by composing other functions whose derivatives are known. back - propagation is an algorithm that computes the chain rule, with a specific order of operations that is highly [UNK]. let x be a real number, and let f and g both be functions mapping from a real number to a real number. suppose that y = g ( x ) and z = f ( g ( x ) ) = f ( y ). then the chain rule states that dz dx = dz dy dy dx. ( 6. 44 ) we can generalize this beyond the scalar case. suppose that
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 220
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
( g ( x ) ) = f ( y ). then the chain rule states that dz dx = dz dy dy dx. ( 6. 44 ) we can generalize this beyond the scalar case. suppose that x ∈rm, y ∈rn, 205
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 220
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks z x y ( a ) × x w ( b ) u ( 1 ) u ( 1 ) dot b u ( 2 ) u ( 2 ) + [UNK] σ ( c ) x w u ( 1 ) u ( 1 ) matmul b u ( 2 ) u ( 2 ) + h relu x w ( d ) [UNK] dot λ u ( 1 ) u ( 1 ) sqr u ( 2 ) u ( 2 ) sum u ( 3 ) u ( 3 ) × figure 6. 8 : examples of computational graphs. the graph using the ( a ) × operation to compute z = xy. the graph for the logistic regression prediction ( b ) [UNK] = σ xw + b. some of the intermediate expressions do not have names in the algebraic expression but need names in the graph. we simply name the i - th such variable u ( ) i. the ( c ) computational graph for the expression h = max { 0, xw + b }, which computes a design matrix of rectified linear unit activations h given a design matrix containing a minibatch of inputs x. examples a – c applied at most one operation to each variable, but it ( d ) is possible to
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 221
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
which computes a design matrix of rectified linear unit activations h given a design matrix containing a minibatch of inputs x. examples a – c applied at most one operation to each variable, but it ( d ) is possible to apply more than one operation. here we show a computation graph that applies more than one operation to the weights w of a linear regression model. the weights are used to make both the prediction [UNK] and the weight decay penalty λ i w2 i. 206
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 221
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks g maps from rm to rn, and f maps from rn to r. if y = g ( x ) and z = f ( y ), then ∂z ∂xi = j ∂z ∂yj ∂yj ∂xi. ( 6. 45 ) in vector notation, this may be equivalently written as ∇xz = ∂y ∂x ∇y z, ( 6. 46 ) where ∂y ∂x is the jacobian matrix of. n m × g from this we see that the gradient of a variable x can be obtained by multiplying a jacobian matrix ∂y ∂x by a gradient ∇yz. the back - propagation algorithm consists of performing such a jacobian - gradient product for each operation in the graph. usually we do not apply the back - propagation algorithm merely to vectors, but rather to tensors of arbitrary dimensionality. conceptually, this is exactly the same as back - propagation with vectors. the only [UNK] is how the numbers are arranged in a grid to form a tensor. we could imagine flattening each tensor into a vector before we run back - propagation, computing a vector - valued gradient, and then reshaping the gradient back into a tensor. in this rear
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 222
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
are arranged in a grid to form a tensor. we could imagine flattening each tensor into a vector before we run back - propagation, computing a vector - valued gradient, and then reshaping the gradient back into a tensor. in this rearranged view, back - propagation is still just multiplying jacobians by gradients. to denote the gradient of a value z with respect to a tensor x, we write ∇xz, just as if x were a vector. the indices into x now have multiple coordinates — for example, a 3 - d tensor is indexed by three coordinates. we can abstract this away by using a single variable i to represent the complete tuple of indices. for all possible index tuples i, ( ∇xz ) i gives ∂z ∂xi. this is exactly the same as how for all possible integer indices i into a vector, ( ∇x z ) i gives ∂z ∂xi. using this notation, we can write the chain rule as it applies to tensors. if and, then y x = ( g ) z f = ( ) y ∇x z = j ( ∇xyj ) ∂z ∂yj. ( 6. 47 ) 6. 5. 3 recursively applying the chain rule
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 222
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. if and, then y x = ( g ) z f = ( ) y ∇x z = j ( ∇xyj ) ∂z ∂yj. ( 6. 47 ) 6. 5. 3 recursively applying the chain rule to obtain backprop using the chain rule, it is straightforward to write down an algebraic expression for the gradient of a scalar with respect to any node in the computational graph that produced that scalar. however, actually evaluating that expression in a computer introduces some extra considerations. specifically, many subexpressions may be repeated several times within the overall expression for the gradient. any procedure that computes the gradient 207
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 222
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks will need to choose whether to store these subexpressions or to recompute them several times. an example of how these repeated subexpressions arise is given in figure. in some cases, computing the same subexpression twice would simply 6. 9 be wasteful. for complicated graphs, there can be exponentially many of these wasted computations, making a naive implementation of the chain rule infeasible. in other cases, computing the same subexpression twice could be a valid way to reduce memory consumption at the cost of higher runtime. we first begin by a version of the back - propagation algorithm that specifies the actual gradient computation directly ( algorithm along with algorithm for the 6. 2 6. 1 associated forward computation ), in the order it will actually be done and according to the recursive application of chain rule. one could either directly perform these computations or view the description of the algorithm as a symbolic specification of the computational graph for computing the back - propagation. however, this formulation does not make explicit the manipulation and the construction of the symbolic graph that performs the gradient computation. such a formulation is presented below in section, with algorithm, where
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 223
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
##ification of the computational graph for computing the back - propagation. however, this formulation does not make explicit the manipulation and the construction of the symbolic graph that performs the gradient computation. such a formulation is presented below in section, with algorithm, where we also generalize to 6. 5. 6 6. 5 nodes that contain arbitrary tensors. first consider a computational graph describing how to compute a single scalar u ( ) n ( say the loss on a training example ). this scalar is the quantity whose gradient we want to obtain, with respect to the ni input nodes u ( 1 ) to u ( ni ). in other words we wish to compute ∂u ( ) n ∂u ( ) i for all i ∈ { 1, 2,..., ni }. in the application of back - propagation to computing gradients for gradient descent over parameters, u ( ) n will be the cost associated with an example or a minibatch, while u ( 1 ) to u ( ni ) correspond to the parameters of the model. we will assume that the nodes of the graph have been ordered in such a way that we can compute their output one after the other, starting at u ( ni + 1 ) and going up to u ( ) n
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 223
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
to the parameters of the model. we will assume that the nodes of the graph have been ordered in such a way that we can compute their output one after the other, starting at u ( ni + 1 ) and going up to u ( ) n. as defined in algorithm, each node 6. 1 u ( ) i is associated with an operation f ( ) i and is computed by evaluating the function u ( ) i = ( f a ( ) i ) ( 6. 48 ) where a ( ) i is the set of all nodes that are parents of u ( ) i. that algorithm specifies the forward propagation computation, which we could put in a graph g. in order to perform back - propagation, we can construct a computational graph that depends ong and adds to it an extra set of nodes. these form a subgraph b with one node per node of g. computation in b proceeds in exactly the reverse of the order of computation in g, and each node of b computes the derivative ∂u ( ) n ∂u ( ) i associated with the forward graph node u ( ) i. this is done 208
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 223
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks algorithm 6. 1 a procedure that performs the computations mapping ni inputs u ( 1 ) to u ( ni ) to an output u ( ) n. this defines a computational graph where each node computes numerical value u ( ) i by applying a function f ( ) i to the set of arguments a ( ) i that comprises the values of previous nodes u ( ) j, j < i, with j pa ∈ ( u ( ) i ). the input to the computational graph is the vector x, and is set into the first ni nodes u ( 1 ) to u ( ni ). the output of the computational graph is read [UNK] last ( output ) node u ( ) n. for i,..., n = 1 i do u ( ) i ←xi end for for i n = i + 1,..., n do a ( ) i ← { u ( ) j | ∈ j pa u ( ( ) i ) } u ( ) i ←f ( ) i ( a ( ) i ) end for return u ( ) n using the chain rule with respect to scalar output u ( ) n : ∂u ( ) n ∂u ( ) j = i j p
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 224
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
( ) i ←f ( ) i ( a ( ) i ) end for return u ( ) n using the chain rule with respect to scalar output u ( ) n : ∂u ( ) n ∂u ( ) j = i j p a u : ∈ ( ( ) i ) ∂u ( ) n ∂u ( ) i ∂u ( ) i ∂u ( ) j ( 6. 49 ) as specified by algorithm. the subgraph 6. 2 b contains exactly one edge for each edge from node u ( ) j to node u ( ) i of g. the edge from u ( ) j to u ( ) i is associated with the computation of ∂u ( ) i ∂u ( ) j. in addition, a dot product is performed for each node, between the gradient already computed with respect to nodes u ( ) i that are children of u ( ) j and the vector containing the partial derivatives ∂u ( ) i ∂u ( ) j for the same children nodes u ( ) i. to summarize, the amount of computation required for performing the back - propagation scales linearly with the number of edges in g, where the computation for each edge corresponds to computing a partial derivative ( of one node with respect to
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 224
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
( ) i. to summarize, the amount of computation required for performing the back - propagation scales linearly with the number of edges in g, where the computation for each edge corresponds to computing a partial derivative ( of one node with respect to one of its parents ) as well as performing one multiplication and one addition. below, we generalize this analysis to tensor - valued nodes, which is just a way to group multiple scalar values in the same node and enable more [UNK] implementations. the back - propagation algorithm is designed to reduce the number of common subexpressions without regard to memory. specifically, it performs on the order of one jacobian product per node in the graph. this can be seen from the fact that backprop ( algorithm ) visits each edge from node 6. 2 u ( ) j to node u ( ) i of the graph exactly once in order to obtain the associated partial derivative ∂u ( ) i ∂u ( ) j. 209
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 224
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks algorithm 6. 2 simplified version of the back - propagation algorithm for computing the derivatives of u ( ) n with respect to the variables in the graph. this example is intended to further understanding by showing a simplified case where all variables are scalars, and we wish to compute the derivatives with respect to u ( 1 ),..., u ( ni ). this simplified version computes the derivatives of all nodes in the graph. the computational cost of this algorithm is proportional to the number of edges in the graph, assuming that the partial derivative associated with each edge requires a constant time. this is of the same order as the number of computations for the forward propagation. each ∂u ( ) i ∂u ( ) j is a function of the parents u ( ) j of u ( ) i, thus linking the nodes of the forward graph to those added for the back - propagation graph. run forward propagation ( algorithm for this example ) to obtain the activa - 6. 1 tions of the network initialize grad _ table, a data structure that will store the derivatives that have been computed. the entry grad table _ [ u ( ) i ] will
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 225
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
this example ) to obtain the activa - 6. 1 tions of the network initialize grad _ table, a data structure that will store the derivatives that have been computed. the entry grad table _ [ u ( ) i ] will store the computed value of ∂u ( ) n ∂u ( ) i. grad table _ [ u ( ) n ] 1 ← for do j n = −1 down to 1 the next line computes ∂u ( ) n ∂u ( ) j = i j p a u : ∈ ( ( ) i ) ∂u ( ) n ∂u ( ) i ∂u ( ) i ∂u ( ) j using stored values : grad table _ [ u ( ) j ] ← i j p a u : ∈ ( ( ) i ) grad table _ [ u ( ) i ] ∂u ( ) i ∂u ( ) j end for return { grad table _ [ u ( ) i ] = 1 | i,..., ni } back - propagation thus avoids the exponential explosion in repeated subexpressions. however, other algorithms may be able to avoid more subexpressions by performing simplifications on the computational graph, or may be able to conserve
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 225
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
ni } back - propagation thus avoids the exponential explosion in repeated subexpressions. however, other algorithms may be able to avoid more subexpressions by performing simplifications on the computational graph, or may be able to conserve memory by recomputing rather than storing some subexpressions. we will revisit these ideas after describing the back - propagation algorithm itself. 6. 5. 4 back - propagation computation in fully - connected mlp to clarify the above definition of the back - propagation computation, let us consider the specific graph associated with a fully - connected multi - layer mlp. algorithm first shows the forward propagation, which maps parameters to 6. 3 the supervised loss l ( [UNK] y, ) associated with a single ( input, target ) training example ( ) x y,, with [UNK] the output of the neural network when is provided in input. x algorithm then shows the corresponding computation to be done for 6. 4 210
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 225
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks z x y w f f f figure 6. 9 : a computational graph that results in repeated subexpressions when computing the gradient. let w ∈r be the input to the graph. we use the same function f : r r → as the operation that we apply at every step of a chain : x = f ( w ), y = f ( x ), z = f ( y ). to compute ∂z ∂w, we apply equation and obtain : 6. 44 ∂z ∂w ( 6. 50 ) = ∂z ∂y ∂y ∂x ∂x ∂w ( 6. 51 ) = f ( ) y f ( ) x f ( ) w ( 6. 52 ) = f ( ( ( ) ) ) f f w f ( ( ) ) f w f ( ) w ( 6. 53 ) equation suggests an implementation in which we compute the value of 6. 52 f ( w ) only once and store it in the variable x. this is the approach taken by the back - propagation algorithm. an alternative approach is suggested by equation, where the subexpression 6. 53 f ( w ) appears more than once. in the alternative approach, f ( w ) is rec
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 226
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
. this is the approach taken by the back - propagation algorithm. an alternative approach is suggested by equation, where the subexpression 6. 53 f ( w ) appears more than once. in the alternative approach, f ( w ) is recomputed each time it is needed. when the memory required to store the value of these expressions is low, the back - propagation approach of equation is clearly preferable because of its reduced 6. 52 runtime. however, equation is also a valid implementation of the chain rule, and is 6. 53 useful when memory is limited. 211
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 226
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks applying the back - propagation algorithm to this graph. algorithms and are demonstrations that are chosen to be simple and 6. 3 6. 4 straightforward to understand. however, they are specialized to one specific problem. modern software implementations are based on the generalized form of back - propagation described in section below, which can accommodate any compu - 6. 5. 6 tational graph by explicitly manipulating a data structure for representing symbolic computation. algorithm 6. 3 forward propagation through a typical deep neural network and the computation of the cost function. the loss l ( [UNK] y, ) depends on the output [UNK] and on the target y ( see section for examples of loss functions ). to 6. 2. 1. 1 obtain the total cost j, the loss may be added to a regularizer ω ( θ ), where θ contains all the parameters ( weights and biases ). algorithm shows how to 6. 4 compute gradients of j with respect to parameters w and b. for simplicity, this demonstration uses only a single input example x. practical applications should use a minibatch. see section for a more realistic demonstration. 6. 5. 7 require : network depth, l require : w ( ) i, i,
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 227
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
for simplicity, this demonstration uses only a single input example x. practical applications should use a minibatch. see section for a more realistic demonstration. 6. 5. 7 require : network depth, l require : w ( ) i, i,..., l, ∈ { 1 } the weight matrices of the model require : b ( ) i, i,..., l, ∈ { 1 } the bias parameters of the model require : x, the input to process require : y, the target output h ( 0 ) = x for do k,..., l = 1 a ( ) k = b ( ) k + w ( ) k h ( 1 ) k− h ( ) k = ( f a ( ) k ) end for [UNK] h = ( ) l j l = ( [UNK] y, ) + ω ( ) λ θ 6. 5. 5 symbol - to - symbol derivatives algebraic expressions and computational graphs both operate on symbols, or variables that do not have specific values. these algebraic and graph - based representations are called symbolic representations. when we actually use or train a neural network, we must assign specific values to these symbols. we replace a symbolic input to the network x with a spec
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 227
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
##fic values. these algebraic and graph - based representations are called symbolic representations. when we actually use or train a neural network, we must assign specific values to these symbols. we replace a symbolic input to the network x with a specific numeric value, such as [ 1 2 3 765 1 8 ].,., −.. 212
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 227
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks algorithm 6. 4 backward computation for the deep neural network of algo - rithm, which uses in addition to the input 6. 3 x a target y. this computation yields the gradients on the activations a ( ) k for each layer k, starting from the output layer and going backwards to the first hidden layer. from these gradients, which can be interpreted as an indication of how each layer ’ s output should change to reduce error, one can obtain the gradient on the parameters of each layer. the gradients on weights and biases can be immediately used as part of a stochas - tic gradient update ( performing the update right after the gradients have been computed ) or used with other gradient - based optimization methods. after the forward computation, compute the gradient on the output layer : g [UNK] = [UNK] ( [UNK] y, ) for do k l, l,..., = −1 1 convert the gradient on the layer ’ s output into a gradient into the pre - nonlinearity activation ( element - wise multiplication if is element - wise ) : f g ←∇a ( ) k j f = g ( a ( ) k ) compute gradients on weights and biases ( including
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 228
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
into a gradient into the pre - nonlinearity activation ( element - wise multiplication if is element - wise ) : f g ←∇a ( ) k j f = g ( a ( ) k ) compute gradients on weights and biases ( including the regularization term, where needed ) : ∇b ( ) k j λ = + g ∇b ( ) k ω ( ) θ ∇w ( ) k j = g h ( 1 ) k− + λ∇w ( ) k ω ( ) θ propagate the gradients w. r. t. the next lower - level hidden layer ’ s activations : g ←∇h ( 1 ) k−j = w ( ) k g end for 213
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 228
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks z x y w f f f z x y w f f f dz dy dz dy f dy dx dy dx f dz dx dz dx × dx dw dx dw f dz dw dz dw × figure 6. 10 : an example of the symbol - to - symbol approach to computing derivatives. in this approach, the back - propagation algorithm does not need to ever access any actual specific numeric values. instead, it adds nodes to a computational graph describing how to compute these derivatives. a generic graph evaluation engine can later compute the derivatives for any specific numeric values. ( left ) in this example, we begin with a graph representing z = f ( f ( f ( w ) ) ). we run the back - propagation algorithm, instructing ( right ) it to construct the graph for the expression corresponding to dz dw. in this example, we do not explain how the back - propagation algorithm works. the purpose is only to illustrate what the desired result is : a computational graph with a symbolic description of the derivative. some approaches to back - propagation take a computational graph and a set of numerical values
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 229
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
do not explain how the back - propagation algorithm works. the purpose is only to illustrate what the desired result is : a computational graph with a symbolic description of the derivative. some approaches to back - propagation take a computational graph and a set of numerical values for the inputs to the graph, then return a set of numerical values describing the gradient at those input values. we call this approach “ symbol - to - number ” [UNK]. this is the approach used by libraries such as torch (, ) and [UNK] (, ). collobert et al. 2011b jia 2013 another approach is to take a computational graph and add additional nodes to the graph that provide a symbolic description of the desired derivatives. this is the approach taken by theano (, ;, ) bergstra et al. 2010 bastien et al. 2012 and tensorflow (, ). an example of how this approach works abadi et al. 2015 is illustrated in figure. the primary advantage of this approach is that 6. 10 the derivatives are described in the same language as the original expression. because the derivatives are just another computational graph, it is possible to run back - propagation again, [UNK] the derivatives in order to obtain higher derivatives. computation of higher - order derivatives is described in section.
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 229
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
described in the same language as the original expression. because the derivatives are just another computational graph, it is possible to run back - propagation again, [UNK] the derivatives in order to obtain higher derivatives. computation of higher - order derivatives is described in section. 6. 5. 10 we will use the latter approach and describe the back - propagation algorithm in 214
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 229
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks terms of constructing a computational graph for the derivatives. any subset of the graph may then be evaluated using specific numerical values at a later time. this allows us to avoid specifying exactly when each operation should be computed. instead, a generic graph evaluation engine can evaluate every node as soon as its parents ’ values are available. the description of the symbol - to - symbol based approach subsumes the symbol - to - number approach. the symbol - to - number approach can be understood as performing exactly the same computations as are done in the graph built by the symbol - to - symbol approach. the key [UNK] is that the symbol - to - number approach does not expose the graph. 6. 5. 6 general back - propagation the back - propagation algorithm is very simple. to compute the gradient of some scalar z with respect to one of its ancestors x in the graph, we begin by observing that the gradient with respect to z is given by dz dz = 1. we can then compute the gradient with respect to each parent of z in the graph by multiplying the current gradient by the jacobian of the operation that produced z. we continue multiplying by jacobians traveling backwards through the graph in
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 230
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
1. we can then compute the gradient with respect to each parent of z in the graph by multiplying the current gradient by the jacobian of the operation that produced z. we continue multiplying by jacobians traveling backwards through the graph in this way until we reach x. for any node that may be reached by going backwards from z through two or more paths, we simply sum the gradients arriving from [UNK] paths at that node. more formally, each node in the graph g corresponds to a variable. to achieve maximum generality, we describe this variable as being a tensor v. tensor can in general have any number of dimensions. they subsume scalars, vectors, and matrices. we assume that each variable is associated with the following subroutines : v • get operation _ ( v ) : this returns the operation that computes v, repre - sented by the edges coming into v in the computational graph. for example, there may be a python or c + + class representing the matrix multiplication operation, and the get _ operation function. suppose we have a variable that is created by matrix multiplication, c = ab. then get operation _ ( v ) returns a pointer to an instance of the corresponding c + + class. • get consumers _
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 230
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
operation, and the get _ operation function. suppose we have a variable that is created by matrix multiplication, c = ab. then get operation _ ( v ) returns a pointer to an instance of the corresponding c + + class. • get consumers _ ( v, g ) : this returns the list of variables that are children of v in the computational graph. g • g get inputs _ ( v, ) : this returns the list of variables that are parents of v in the computational graph. g 215
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 230
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks each operation op is also associated with a bprop operation. this bprop operation can compute a jacobian - vector product as described by equation. 6. 47 this is how the back - propagation algorithm is able to achieve great generality. each operation is responsible for knowing how to back - propagate through the edges in the graph that it participates in. for example, we might use a matrix multiplication operation to create a variable c = ab. suppose that the gradient of a scalar z with respect to c is given by g. the matrix multiplication operation is responsible for defining two back - propagation rules, one for each of its input arguments. if we call the bprop method to request the gradient with respect to a given that the gradient on the output is g, then the bprop method of the matrix multiplication operation must state that the gradient with respect to a is given by gb. likewise, if we call the bprop method to request the gradient with respect to b, then the matrix operation is responsible for implementing the bprop method and specifying that the desired gradient is given by ag. the back - propagation algorithm itself does not need to know any [UNK] rules. it only needs to call each operation ’ s bp
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 231
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
, then the matrix operation is responsible for implementing the bprop method and specifying that the desired gradient is given by ag. the back - propagation algorithm itself does not need to know any [UNK] rules. it only needs to call each operation ’ s bprop rules with the right arguments. formally, op bprop inputs. (,, x g ) must return i ( ∇xop f inputs. ( ) i ) gi, ( 6. 54 ) which is just an implementation of the chain rule as expressed in equation. 6. 47 here, inputs is a list of inputs that are supplied to the operation, op. f is the mathematical function that the operation implements, x is the input whose gradient we wish to compute, and is the gradient on the output of the operation. g the op. bprop method should always pretend that all of its inputs are distinct from each other, even if they are not. for example, if the mul operator is passed two copies of x to compute x2, the op. bprop method should still return x as the derivative with respect to both inputs. the back - propagation algorithm will later add both of these arguments together to obtain 2x, which is the correct total derivative on. x software implementations of back - propagation usually
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 231
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
bprop method should still return x as the derivative with respect to both inputs. the back - propagation algorithm will later add both of these arguments together to obtain 2x, which is the correct total derivative on. x software implementations of back - propagation usually provide both the opera - tions and their bprop methods, so that users of deep learning software libraries are able to back - propagate through graphs built using common operations like matrix multiplication, exponents, logarithms, and so on. software engineers who build a new implementation of back - propagation or advanced users who need to add their own operation to an existing library must usually derive the op. bprop method for any new operations manually. the back - propagation algorithm is formally described in algorithm. 6. 5 216
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 231
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks algorithm 6. 5 the outermost skeleton of the back - propagation algorithm. this portion does simple setup and cleanup work. most of the important work happens in the subroutine of algorithm build _ grad 6. 6. require : t, the target set of variables whose gradients must be computed. require : g, the computational graph require : z, the variable to be [UNK] let gbe g pruned to contain only nodes that are ancestors of z and descendents of nodes in. t initialize, a data structure associating tensors to their gradients grad _ table grad table _ [ ] 1 z ← for do v in t build grad _ ( v,, g g, grad table _ ) end for return restricted to grad _ table t in section, we explained that back - propagation was developed in order to 6. 5. 2 avoid computing the same subexpression in the chain rule multiple times. the naive algorithm could have exponential runtime due to these repeated subexpressions. now that we have specified the back - propagation algorithm, we can understand its computational cost. if we assume that each operation evaluation has roughly the same cost, then we may
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 232
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
have exponential runtime due to these repeated subexpressions. now that we have specified the back - propagation algorithm, we can understand its computational cost. if we assume that each operation evaluation has roughly the same cost, then we may analyze the computational cost in terms of the number of operations executed. keep in mind here that we refer to an operation as the fundamental unit of our computational graph, which might actually consist of very many arithmetic operations ( for example, we might have a graph that treats matrix multiplication as a single operation ). computing a gradient in a graph with n nodes will never execute more than o ( n2 ) operations or store the output of more than o ( n2 ) operations. here we are counting operations in the computational graph, not individual operations executed by the underlying hardware, so it is important to remember that the runtime of each operation may be highly variable. for example, multiplying two matrices that each contain millions of entries might correspond to a single operation in the graph. we can see that computing the gradient requires as most o ( n2 ) operations because the forward propagation stage will at worst execute all n nodes in the original graph ( depending on which values we want to compute, we may not need to execute the entire graph
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 232
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
can see that computing the gradient requires as most o ( n2 ) operations because the forward propagation stage will at worst execute all n nodes in the original graph ( depending on which values we want to compute, we may not need to execute the entire graph ). the back - propagation algorithm adds one jacobian - vector product, which should be expressed with o ( 1 ) nodes, per edge in the original graph. because the computational graph is a directed acyclic graph it has at most o ( n2 ) edges. for the kinds of graphs that are commonly used in practice, the situation is even better. most neural network cost functions are 217
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 232
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
chapter 6. deep feedforward networks algorithm 6. 6 the inner loop subroutine build grad _ ( v,, g g, grad table _ ) of the back - propagation algorithm, called by the back - propagation algorithm defined in algorithm. 6. 5 require : v, the variable whose gradient should be added to and. g grad _ table require : g, the graph to modify. require : g, the restriction of to nodes that participate in the gradient. g require : grad _ table, a data structure mapping nodes to their gradients if then v is in grad _ table return _ grad table [ ] v end if i ←1 for c v in _ get consumers (, g ) do op get operation ← _ ( ) c d c ←build grad _ (,, g g, grad table _ ) g ( ) i ← g op bprop get inputs. ( _ ( c, ) ),, v d i i ← + 1 end for g ← ig ( ) i grad table _ [ ] = v g insert and the operations creating it into g g return g roughly chain - structured, causing back - propagation to have o ( n ) cost. this is far
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 233
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
1 end for g ← ig ( ) i grad table _ [ ] = v g insert and the operations creating it into g g return g roughly chain - structured, causing back - propagation to have o ( n ) cost. this is far better than the naive approach, which might need to execute exponentially many nodes. this potentially exponential cost can be seen by expanding and rewriting the recursive chain rule ( equation ) non - recursively : 6. 49 ∂u ( ) n ∂u ( ) j = path ( u ( π1 ), u ( π2 ),..., u ( πt ) ), from π1 = to j πt = n t k = 2 ∂u ( πk ) ∂u ( πk−1 ). ( 6. 55 ) since the number of paths from node j to node n can grow exponentially in the length of these paths, the number of terms in the above sum, which is the number of such paths, can grow exponentially with the depth of the forward propagation graph. this large cost would be incurred because the same computation for ∂u ( ) i ∂u ( ) j would be redone many times. to avoid such recomputation, we can think of
|
/home/ricoiban/GEMMA/mnlp_chatsplaining/RAG/Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org).pdf
| 233
|
Deep Learning by Ian Goodfellow, Yoshua Bengio, Aaron Courville (z-lib.org)
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.