# W4 - Programming assignment 1

**URL:** <https://community.deeplearning.ai/t/w4-programming-assignment-1/225155>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [November 1, 2022, 10:44am UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155 "2022-11-01T10:44:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mansoor\_hasani](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mansoor\_hasani](https://community.deeplearning.ai/u/mansoor_hasani)\
**Post date:** [November 1, 2022, 10:44am UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/1 "2022-11-01T10:44:16Z")

</div>

Hello

In the linear\_activation\_backward function, I have to calculate the dA\_prev, dW, and db variables for calculating them W and A variables are needed which aren’t available, what should I do?

Best,  
Mansoor

---

<div class="post-metadata">

**Author:** ![kchong37](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kchong37/32/162798_2.png) [@kchong37](https://community.deeplearning.ai/u/kchong37)\
**Post date:** [November 1, 2022, 12:13pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/2 "2022-11-01T12:13:45Z")

</div>

Hi Mansoor,

Are you referring to Exercise 8? If so, check out the hints before the problem (6.2 Linear Activation Backward) you will see some pre-implemented functions already imported in the assignment there. Hope it helps!

Best,  
Kezhen

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [November 1, 2022, 3:35pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/3 "2022-11-01T15:35:59Z")

</div>

That is the purpose of the cache variable that is passed in. Have a closer look at how those are constructed and what they contain.

---

<div class="post-metadata">

**Author:** ![mansoor\_hasani](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mansoor\_hasani](https://community.deeplearning.ai/u/mansoor_hasani)\
**Post date:** [November 4, 2022, 2:31pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/4 "2022-11-04T14:31:42Z")

</div>

Thanks Kchong for your response,

The pre-implemented function needs a cache variable that is different from the cache variable which is sent to this function

---

<div class="post-metadata">

**Author:** ![mansoor\_hasani](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mansoor\_hasani](https://community.deeplearning.ai/u/mansoor_hasani)\
**Post date:** [November 4, 2022, 2:33pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/5 "2022-11-04T14:33:55Z")

</div>

Thank you Paulinpaloalto for your response,

The cache variable for this function contains, linear\_cache and activation\_cache variables although it should contain A\_prev, W, b variables

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [November 4, 2022, 2:37pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/6 "2022-11-04T14:37:28Z")

</div>

Well, that’s the first level of analysis. Now you need to look at what is contained in `linear_cache` and `activation_cache`.

---

<div class="post-metadata">

**Author:** ![mansoor\_hasani](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mansoor\_hasani](https://community.deeplearning.ai/u/mansoor_hasani)\
**Post date:** [November 4, 2022, 3:06pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/7 "2022-11-04T15:06:44Z")

</div>

> [@paulinpaloalto](#):
>
> `linear_cache`

in linear\_cache is the Z variable and in the activation\_cache is the A variable

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [November 4, 2022, 4:03pm UTC](https://community.deeplearning.ai/t/w4-programming-assignment-1/225155/8 "2022-11-04T16:03:51Z")

</div>

You are not interpreting the code correctly. The activation cache contains Z and the linear cache is a 3-tuple that contains (A, W, b). Look at where those cache values are generated: by `linear_forward` and by `sigmoid` and `relu`. Then `linear_activation_forward` concatenates them to make the full cache entry for each layer. The code is all there for you to see. You can find the code for sigmoid and relu by clicking “File → Open” and then opening the utility python file.
