# W3\_E4: AssertionError: for variable Z2

**URL:** <https://community.deeplearning.ai/t/w3-e4-assertionerror-for-variable-z2/471477>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [October 17, 2023, 7:43am UTC](https://community.deeplearning.ai/t/w3-e4-assertionerror-for-variable-z2/471477 "2023-10-17T07:43:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anurag\_Dixit](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Anurag\_Dixit](https://community.deeplearning.ai/u/Anurag_Dixit)\
**Post date:** [October 17, 2023, 7:43am UTC](https://community.deeplearning.ai/t/w3-e4-assertionerror-for-variable-z2/471477/1 "2023-10-17T07:43:27Z")

</div>

Hello Everyone,  
I am trying implementing E4.

> **Intent** : Implement → Z2 = W2 . A1 + b2

> **Implementation** : Although I have implemented this earlier, I continue to get Assertion Error.  
> (Attached picture)

> **QUERY** : I tried below options, but issue still persists.  
> Z2 = np.dot(W2,A1) + b2 # FAIL  
> # Z2 = np.dot(np.transpose(W2),A1) + b2 # FAIL. Value Error.  
> # Z2 = np.dot(W2,np.transpose(A1)) + b2 # FAIL. Value Error.  
> # Z2 = np.dot(A1,W2) + b2 # FAIL. Value Error.  
> # Z2 = np.dot(A1,np.transpose(W2)) + b2 # FAIL. Value Error.  
> # Z2 = np.dot(np.transpose(A1),W2) + b2 # FAIL. Value Error.

Please assist.  
Sincerely,  
A

> **Error Observed** :

A2 = [[-0.86360952 -0.86388209 -0.86355916]]

* * *

AssertionError Traceback (most recent call last)  
 in   
3 print("A2 = " + str(A2))  
4  
----\> 5 forward\_propagation\_test(forward\_propagation)

~/work/release/W3A1/public\_tests.py in forward\_propagation\_test(target)  
108 assert output[1][“Z2”].shape == expected\_Z2.shape, f"Wrong shape for cache[‘Z2’]."  
109  
 → 110 assert np.allclose(output[0], expected\_A2), “Wrong values for A2”  
111 assert np.allclose(output[1][“Z1”], expected\_Z1), “Wrong values for cache[‘Z1’]”  
112 assert np.allclose(output[1][“A1”], expected\_A1), “Wrong values for cache[‘A1’]”

AssertionError: Wrong values for A2

Expected output

A2 = [[0.21292656 0.21274673 0.21295976]]  
All tests passed!

 ![Screen Shot 2023-10-17 at 12.37.05 AM](https://global.discourse-cdn.com/dlai/original/3X/c/c/ccb2ede6b8e6ef46fbf8524b50a29f28ca61b77d.png)

---

<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:** [October 17, 2023, 11:33am UTC](https://community.deeplearning.ai/t/w3-e4-assertionerror-for-variable-z2/471477/2 "2023-10-17T11:33:40Z")

</div>

But your error says wrong values for A2. So, why you are focusing on Z2? You showed six different ways to implement Z2. Instead of trying one after another, use your intuition to find out which way is correct and then just make sure you use correct activation function for A2.

---

<div class="post-metadata">

**Author:** ![Anurag\_Dixit](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Anurag\_Dixit](https://community.deeplearning.ai/u/Anurag_Dixit)\
**Post date:** [October 20, 2023, 7:16am UTC](https://community.deeplearning.ai/t/w3-e4-assertionerror-for-variable-z2/471477/3 "2023-10-20T07:16:20Z")

</div>

Good catch…my bad 🙂  
Thanks a lot.  
Sincerely,  
A
