In plain words: A guide to the matrix calculus behind training neural networks, needing only first-year calculus and refreshing the basics as it goes. It ends with a reference section collecting every key rule, for readers who already know neural network basics and want the underlying math.
Abstract · The Matrix Calculus You Need For Deep Learning
This paper is an attempt to explain all the matrix calculus you need in order to understand the training of deep neural networks. We assume no math knowledge beyond what you learned in calculus 1, and provide links to help you refresh the necessary math where needed. Note that you do not need to understand this material before you start learning to train and use deep learning in practice; rather, this material is for those who are already familiar with the basics of neural networks, and wish to deepen their understanding of the underlying math. Don't worry if you get stuck at some point along the way---just go back and reread the previous section, and try writing down and working through some examples. And if you're still stuck, we're happy to answer your questions in the Theory category at forums.fast.ai. Note: There is a reference section at the end of the paper summarizing all the key matrix calculus rules and terminology discussed here. See related articles at http://explained.ai
Terence Parr, Jeremy Howard
arXiv:1802.01528 · cs.LG, stat.ML · submitted Feb 5, 2018 · updated Jul 2, 2018
abstract · pdf · html · PDF version of mobile/web friendly version http://explained.ai/matrix-calculus/index.html
(1) f: R^n -> R is a vector
(2) f: R -> R^n is a vector
(3) f: R^m -> R^n is an n x m matrix (the Jacobian)
(*) f(x)=x^tAx is f'(x)=(A + A^t)x (this is an example of (1))
(**) and that the derivative (gradient) of (1) gives you (3) with m=n, and in this case the derivative of (3) will be symmetric (the Hessian).
then just do your best to apply the single variable rules of differentiation (product rule, chain rule, etc.), and then mess around a bit with the result until all the dimensions match up and such that your result matches the appropriate case (1)-(3).
For any more complicated functions you encounter such as the determinant, you can just look up its derivative when needed.