Partial derivative of cost function using chain rule

chain rulepartial derivative

I need to compute the partial derivative of the cost function of a neural network, with respect to $z_1$ and $z_2$. The cost function is defined below:

enter image description here

enter image description here enter image description here

In my attempt to do this:

enter image description here

I calculated both partial derivatives to be essentially the same, I'm not sure this is correct? if its not, could someone point me to where ive gone wrong. thanks – i apolgise for using pictures!

Best Answer

$$c=\ln(e^{z_1}+e^{z_2})-z_y$$ $$\frac{\partial c}{\partial z_1}=\frac{e^{z_1}}{e^{z_1}+e^{z_2}}$$ $$\frac{\partial c}{\partial z_2}=\frac{e^{z_2}}{e^{z_1}+e^{z_2}}$$ remember with partial derivatives: it is the same as taking a derviative but you treat all other varables as constants so for each one we can say: $$c=\ln(e^{z_1}+a_1)-a_2$$ $$\frac{dc}{dz_1}=\frac{e^{z_1}}{e^{z_1}+a_1}$$ now substitute in your other variables as the "constants"


The mistake you made in each step was the following: $$\frac{\partial u_2}{\partial z_1}=\frac{\partial u_2}{\partial z_2}=0$$ Other than this your answer is correct :)

Related Question