Skip to main content
In case you have forgotten the basics of calculus, please review the calculus section before proceeding.
The backpropagation algorithm brought back from the winter neural networks as it made feasible to train very deep architectures by dramatically improving the efficiency of calculating the gradient of the loss with respect to all the network parameters. In this section we will go over the calculation of gradient using an example function and its associated computational graph. The example does not have anything to do with DNNs but that is exactly the point. The essence of backpropagation was known far earlier than its application in DNN. For students that need a refresher on derivatives please go through Khan Academy’s lessons on partial derivatives and gradients. You may need to review also tensor derivatives. For executing the backwards pass, you will need to look up this table for the derivatives of elementary functions.

Calculating the Gradient of a Function

Our goal is to compute the components of the gradient of the function f=[f/x,f/y]T\nabla f = [ \partial f / \partial x , \partial f / \partial y ]^T where, f(x,y)=x+σ(y)σ(x)+(x+y)2f(x, y) = \frac{x + \sigma(y)}{\sigma(x) + (x+y)^2} The computational graph of this function is shown below. Its instructive to print this graph and pencil in all calculations for both this example and others in the backpropagation section. One derivative that we will be using that is not often listed is the derivative of the sigmoid function. The sigmoid derivative can be obtained as follows: Consider f(x)=1σ(x)=1+exf(x)=\dfrac{1}{\sigma(x)} = 1+e^{-x} Then, on the one hand, the chain rule gives f(x)=ddx(1σ(x))=σ(x)σ(x)2 f'(x) = \frac{d}{dx} \biggl( \frac{1}{\sigma(x)} \biggr) = -\frac{\sigma'(x)}{\sigma(x)^2} and on the other hand, f(x)=ddx(1+ex)=ex=1f(x)=11σ(x)=σ(x)1σ(x)f'(x) = \frac{d}{dx} \bigl( 1+e^{-x} \bigr) = -e^{-x} = 1-f(x) = 1 - \frac{1}{\sigma(x)} = \frac{\sigma(x)-1}{\sigma(x)} Equating the two expressions we finally obtain, σ(x)=σ(x)(1σ(x))\sigma'(x) = \sigma(x)(1-\sigma(x)) backpropagation-example-loss

Forward Pass

In the forward pass, the algorithm works bottom up (or left to right depending how the computational graph is represented) and calculates the values of all “gates” (gates are the elementary functions that synthesize the function) of the graph and stores their values into variables as they will be used by the backwards pass. There are eight values stored in this specific example.

Backwards Pass

In the backwards pass, we reverse direction and start at the top or rightmost node (the stored variables) of the graph and compute the input (in the reverse direction) derivative of input of each gate using the template depicted below: backprop-template Backpropagation template based on the chain rule.
river-backpropagation As the previous example indicated, the essence of backpropagation algorithm is that local gradients can be calculated symbolically (using calculus) as they only depend on the simple gate structures and these gradients act as valves in the gradient flow that starts from the top of the network (the value of the flow there is always 1.0) and propagates to the bottom of the graph. Think about it as valves controlling the water flowing down a river delta. Individual flows may also merge like in the example above. This example allowed us to understand how the gates control the flow. We have met add, multiply, branch (split) and one non-linear function. Key references: (Bengio, 2012; Choromanska et al., 2014; Romero et al., 2014; Srivastava et al., 2015; Lin et al., 2016)

References

  • Bengio, Y. (2012). Practical recommendations for gradient-based training of deep architectures.
  • Choromanska, A., Henaff, M., Mathieu, M., Ben Arous, G., LeCun, Y. (2014). The Loss Surfaces of Multilayer Networks.
  • Lin, H., Tegmark, M., Rolnick, D. (2016). Why does deep and cheap learning work so well?.
  • Romero, A., Ballas, N., Kahou, S., Chassang, A., Gatta, C., et al. (2014). FitNets: Hints for Thin Deep Nets.
  • Srivastava, R., Greff, K., Schmidhuber, J. (2015). Highway Networks.