What is reverse mode differentiation?
In deep learning, we use automatic differentiation to compute the derivatives of a function or a neural network. There are two types of automatic differentiation:
Reverse mode differentiation
In this Answer, we will discuss the latter.
Reverse Mode Differentiation
In reverse mode differentiation, we compute the derivative of the computational graph by starting from the final output towards the input variables with the help of the chain rule.
Let us understand the concept of reverse mode differentiation with the help of an example.
Example
Consider a function
The trace graph of this function is given below:
In reverse mode differentiation, we find the derivative of the parent node with respect to the children nodes. Now look at the below-mentioned points, where we will find the derivatives at every node.
We start from
and compute the derivative.
Now, we will find the derivative at
.
Similarly, we find the derivative of
.
Finding the derivative at the node
is tedious, so by using the chain rule, we have:
Now we will find the derivatives at input nodes.
Similarly, for node
.
So, we have calculated the derivatives of all nodes using reverse mode differentiation.
Conclusion
In this Answer, we learned about reverse mode differentiation with the help of an example with its trace graph. We calculated the derivative from the final node towards the input nodes. In essence, reverse mode differentiation is used in machine learning for the backpropagation process and enables efficient computations to find the gradients.
Free Resources