How to take the derivative for the following formula?

73 Views Asked by At

I have this loss function formula (for some given machine learning algorithm), with $L_2$ penalty added to it:

$$L(w_1,w_2) = -6(0.1 \cos(w_1) - w_1^2 - 0.5w_2^7 + \sin(w_2))e^{-w_1^2-w_2^2} + \lambda(w_1^2 + w_2^2).$$

The penalty is $\lambda(w_1^2 + w_2^2)$ and the rest of $L$ is the cost function.

How do I take the derivative for this? or more accurately, I took the derivative without this $\lambda(w_1^2 + w_2^2)$ argument. How do I treat the $\lambda$ according to the derivative of $w_1$ or $w_2$ ? Using the product rule maybe?

Perhaps something like this. Taking the derivative with respect to to $w_1$ and treating $\lambda$ as a constant number: $$(\lambda(w_1^2 + w_2^2))' = 0 \cdot (w_1^2 + w_2^2) + \lambda \cdot 2w_1 = 2\lambda w_1.$$ This would just be added to the derivative of the cost function. Correct me if I'm wrong please.