# W3 unittesting seems failing . All codes output are correct before this line. The unit test is not working

**URL:** <https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510>\
**Category:** Linear Algebra for Machine Learning and Data Sc...\
**Tags:** week-module-3\
**Created:** [June 1, 2023, 10:09am UTC](https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510 "2023-06-01T10:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soumya4](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Soumya4](https://community.deeplearning.ai/u/Soumya4)\
**Post date:** [June 1, 2023, 10:09am UTC](https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510/1 "2023-06-01T10:09:14Z")

</div>

ValueError Traceback (most recent call last)  
 in   
----\> 1 w3\_unittest.test\_forward\_propagation(forward\_propagation)

~/work/w3\_unittest.py in test\_forward\_propagation(target\_forward\_propagation)  
286  
287 for test\_case in test\_cases:  
 → 288 result = target\_forward\_propagation(test\_case[“input”][“X”], test\_case[“input”][“parameters”])  
289  
290 try:

in forward\_propagation(X, parameters)  
19 # Implement Forward Propagation to calculate Z.  
20 ### START CODE HERE ### (~ 2 lines of code)  
—\> 21 Z = W\*X + b  
22 Y\_hat = Z  
23

ValueError: operands could not be broadcast together with shapes (1,2) (2,5)

---

<div class="post-metadata">

**Author:** ![Soumya4](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Soumya4](https://community.deeplearning.ai/u/Soumya4)\
**Post date:** [June 1, 2023, 10:10am UTC](https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510/2 "2023-06-01T10:10:38Z")

</div>

The function is this  
def forward\_propagation(X, parameters):  
“”"  
Argument:  
X – input data of size (n\_x, m)  
parameters – python dictionary containing your parameters (output of initialization function)

```
Returns:
Y_hat -- The output
"""
# Retrieve each parameter from the dictionary "parameters".
### START CODE HERE ### (~ 2 lines of code)
W = parameters["W"]
b = parameters["b"]

### END CODE HERE ###

# Implement Forward Propagation to calculate Z.
### START CODE HERE ### (~ 2 lines of code)
Z = W*X + b
Y_hat = Z

### END CODE HERE ###

assert(Y_hat.shape == (n_y, X.shape[1]))

return Y_hat

```

---

<div class="post-metadata">

**Author:** ![Kic](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kic/32/76339_2.png) [@Kic](https://community.deeplearning.ai/u/Kic)\
**Post date:** [June 1, 2023, 10:43am UTC](https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510/3 "2023-06-01T10:43:28Z")

</div>

Hi @Soumya4

The \* operator preforms element-wise multiplication of two matrices that have the same dimensions. In this case, the two matrices are not the same dimensions as you can see from the error message, they are of shapes (1,2) (2,5).  
You can use a np.matmul() for a matrix multiplication, please see the [**reference menu**.](https://numpy.org/doc/stable/reference/generated/numpy.matmul.html)

---

<div class="post-metadata">

**Author:** ![Soumya4](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Soumya4](https://community.deeplearning.ai/u/Soumya4)\
**Post date:** [June 1, 2023, 11:15am UTC](https://community.deeplearning.ai/t/w3-unittesting-seems-failing-all-codes-output-are-correct-before-this-line-the-unit-test-is-not-working/348510/4 "2023-06-01T11:15:58Z")

</div>

Thanks a lot ! That helped
