# I am not getting dz\[1\] in this image/video snapshot

**URL:** <https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [June 7, 2023, 8:15am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713 "2023-06-07T08:15:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anatom](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/anatom/32/26827_2.png) [@anatom](https://community.deeplearning.ai/u/anatom)\
**Post date:** [June 7, 2023, 8:15am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/1 "2023-06-07T08:15:51Z")

</div>

![image](https://global.discourse-cdn.com/dlai/original/3X/d/6/d62830d7b9e69fc6d38ee37c57868fdbf9eea875.jpeg)  
I also tried to find dz[1] myself but I am not getting half of parts. Can someone please help with this equation.

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [June 7, 2023, 8:50am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/2 "2023-06-07T08:50:55Z")

</div>

Hello @anatom

Which half of the part can you get?

Note that the chain rule actually does not work here, so if that is the part that has the problem, I am afraid the easiest way would be to remember the equation, or you have to derive it the hard way…

[Here](https://community.deeplearning.ai/t/week-3-why-dz-1-w-2-t-dz-2-g-1-z-1/272747/4) is my answer to another question on the same equation. That learner’s focus is on the ordering of the variables in the right hand side. Is that also your focus?

Cheers,  
Raymond

---

<div class="post-metadata">

**Author:** ![anatom](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/anatom/32/26827_2.png) [@anatom](https://community.deeplearning.ai/u/anatom)\
**Post date:** [June 7, 2023, 9:02am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/3 "2023-06-07T09:02:38Z")

</div>

Ah ha yes I was thinking using the same chain rule, I will try to derive the other way out.  
Thanks you & clear skies!

---

<div class="post-metadata">

**Author:** ![anatom](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/anatom/32/26827_2.png) [@anatom](https://community.deeplearning.ai/u/anatom)\
**Post date:** [June 7, 2023, 9:09am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/5 "2023-06-07T09:09:46Z")

</div>

But what’s wrong with using chain rule here ?

---

<div class="post-metadata">

**Author:** ![anatom](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/anatom/32/26827_2.png) [@anatom](https://community.deeplearning.ai/u/anatom)\
**Post date:** [June 7, 2023, 9:19am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/6 "2023-06-07T09:19:04Z")

</div>

Can you write the equation from where I can start of with finding derivative of dz[1]

---

<div class="post-metadata">

**Author:** ![saifkhanengr](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/saifkhanengr/32/152858_2.png) [@saifkhanengr](https://community.deeplearning.ai/u/saifkhanengr)\
**Post date:** [June 7, 2023, 9:52am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/7 "2023-06-07T09:52:45Z")

</div>

Check [this](https://community.deeplearning.ai/t/w2-calculation-of-partial-derivatives/345419/7).

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [June 7, 2023, 10:07am UTC](https://community.deeplearning.ai/t/i-am-not-getting-dz-1-in-this-image-video-snapshot/351713/8 "2023-06-07T10:07:27Z")

</div>

> [@anatom](#):
>
> But what’s wrong with using chain rule here ?

Haha, it just doesn’t work there! It will not give you the correct answer. I believe the post that I shared earlier has a counter-example that showed it doesn’t work.

I have a feeling that my answer is not going to satisfy you… 😆 however, is it good to take something that is not even supposed to work and ask why doesn’t it work? 😏😏😏😏

> [@anatom](#):
>
> Can you write the equation from where I can start of with finding derivative of dz[1]

I suggest you to start with a neural network of 2 layers, and each layer has 2 neurons. Write down all the equations NOT in matrix form but in scalar form. Then derive the gradient formula for each scalar weight (not matrix weight). Finally, put all the scalar weight gradients back to a matrix in the right places, and you will see how you should order W^{[2]} and dz^{[2]} so that the matrix equation will be consistent with your scalar results.

It is a good thing to work with scalar equations and scalar weights because you can finally use the chain rule.

Cheers,  
Raymond

Note that I have quoted in my previous linked post the following:

> [@Week 3: Why dZ^\[1\] = W^\[2\]T dZ^\[2\] \* g^\[1\]'(Z^\[1\])](https://community.deeplearning.ai/t/week-3-why-dz-1-w-2-t-dz-2-g-1-z-1/272747/4):
>
> Because as [the same wikipedia page](https://en.wikipedia.org/wiki/Matrix_calculus) says:
> 
> > Matrix calculus refers to a number of different notations that use matrices and vectors to collect the derivative of each component of the dependent variable with respect to each component of the independent variable.

If you follow my suggestion, and when you put all the scalar weights back to a matrix, you will essentially be “collecting the derivative of each component of the dependent variable with respect to each component of the independent variable” just as what the wikipedia page is talking.
