- Gradient is derivative of several variables.
- I can't understand why is the gradient of a ReLU for X>0 is 1 ? and 0 for x < 0 ?
I tried to search for proof and examples but didn't found any good examples.
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.
Sign up to join this communityThe ReLU function is defined as follows: $f(x) = max(0, x)$, meaning that the output of the function is maximum between the input value and zero. This can also be written as follows:
$ f(x) = \begin{cases} 0 & \text{if } x \leq 0, \\ x & \text{if } x \gt 0 \end{cases} $
If we then simply take the derivate of the two outputs with respect to $x$ we get the gradient for input values below zero and value greater than or equal to zero.
$ f'(x) = \begin{cases} 0 & \text{if } x \leq 0, \\ 1 & \text{if } x \gt 0 \end{cases} $
Therefore the gradient of the ReLU function is zero for values up to and including zero and 1 for positive values.