# When using Absolute Error in Gradient Descent, how to calculate the derivative?

What is the derivative of the Loss Function (Absolute Error) with respect to the feature weights that is used to update the weights?

Couldn't find anything specific about it anywhere.

The gradient of MAE is not continuous in $$y_{pred} = y_{true}$$ and therefore there is no defined (bounded, direction independent) derivative at that point.
Elsewhere you have -1, where $$y_{pred} > y_{true}$$ and +1 where $$y_{pred} < y_{true}$$
• Going by page 360 of Elements of Statistical Learning, the gradient for absolute error loss is $\textrm{sign}[y_i - f(x_i)]$. The sign function is defined at 0, it is 0. So when $y_{pred} = y_{true}$, the gradient would equal 0. – Marjolein Fokkema May 24 at 16:03
You can simply approximate $$f(x)=|x|$$ by $$f(x)=\sqrt{x^2+c}$$ where $$c>0$$. You can also utilize subderivative method.