# C1\_W3 \_Assignment

**URL:** <https://community.deeplearning.ai/t/c1-w3-assignment/312542>\
**Category:** Linear Algebra for Machine Learning and Data Sc...\
**Tags:** week-module-3\
**Created:** [April 21, 2023, 6:20pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542 "2023-04-21T18:20:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somasekhar\_Donthu](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@Somasekhar\_Donthu](https://community.deeplearning.ai/u/Somasekhar_Donthu)\
**Post date:** [April 21, 2023, 6:20pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/1 "2023-04-21T18:20:12Z")

</div>

# Single Perceptron Neural Networks for Linear Regression Assignment

getting below error exercise 4 in 2.3 the loop  
shapes (1,1) and (30,1) not aligned: 1 (dim 1) != 30 (dim 0)  
please guide me

---

<div class="post-metadata">

**Author:** ![yjcb22](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/yjcb22/32/127956_2.png) [@yjcb22](https://community.deeplearning.ai/u/yjcb22)\
**Post date:** [April 21, 2023, 10:54pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/2 "2023-04-21T22:54:09Z")

</div>

Can you please tell me the line where you are getting the error?

Is it when computing Z? or in the assert?

Normally the error will say the line.

---

<div class="post-metadata">

**Author:** ![Somasekhar\_Donthu](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@Somasekhar\_Donthu](https://community.deeplearning.ai/u/Somasekhar_Donthu)\
**Post date:** [April 22, 2023, 4:36am UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/3 "2023-04-22T04:36:43Z")

</div>

ValueError Traceback (most recent call last)  
 in   
----\> 1 Y\_hat = forward\_propagation(X, parameters)  
2  
3 print(Y\_hat)

in forward\_propagation(X, parameters)  
19 ### START CODE HERE ### (~ 2 lines of code)  
20 Z = np.dot(w, X) + b  
—\> 21 Y\_hat = forward\_propagation(X.T, parameters)  
22 ### END CODE HERE ###  
23

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

\< **array\_function** internals\> in dot(\*args, \*\*kwargs)

ValueError: shapes (1,1) and (30,1) not aligned: 1 (dim 1) != 30 (dim 0)

---

<div class="post-metadata">

**Author:** ![Somasekhar\_Donthu](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@Somasekhar\_Donthu](https://community.deeplearning.ai/u/Somasekhar_Donthu)\
**Post date:** [April 22, 2023, 5:37am UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/4 "2023-04-22T05:37:03Z")

</div>

I AM GETTING ALL ERRORS WHEN I GO FOR GRADING BUT IT IS SHOWING ALL TESTS PASSED  
ERROR  
There was a problem compiling the code from your notebook. Details:  
matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)-\>(n?,m?) (size 2 is different from 1)

I HOPE THERE Z A PROBLEM WITH COURSERA …

---

<div class="post-metadata">

**Author:** ![yjcb22](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/yjcb22/32/127956_2.png) [@yjcb22](https://community.deeplearning.ai/u/yjcb22)\
**Post date:** [April 22, 2023, 1:48pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/5 "2023-04-22T13:48:54Z")

</div>

Dear @Somasekhar_Donthu

Please find my comments:

1. I doubt there is an error in the coursera platform because the platform is the same for everybody and I am not getting any error as you can see in the following image:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/1/1/1130923a740634fd8b52da06455c727a63547605.png)

However, everything is possible.

1. Can you please try using np.matmul(W,X) + b instead of the dot product and tell me if you are getting the same error?

2. The initial code defines W with upper case, however, I see you are using it with lower case. Can you please confirm if you change the source code? If so, can you please define W and b like this:

W = parameters[“W”]  
b = parameters[“b”]

---

<div class="post-metadata">

**Author:** ![Syed\_Hassan\_Raahim](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Syed\_Hassan\_Raahim](https://community.deeplearning.ai/u/Syed_Hassan_Raahim)\
**Post date:** [April 23, 2023, 1:02pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/6 "2023-04-23T13:02:05Z")

</div>

Not using np.matmul() was the issue

---

<div class="post-metadata">

**Author:** ![yjcb22](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/yjcb22/32/127956_2.png) [@yjcb22](https://community.deeplearning.ai/u/yjcb22)\
**Post date:** [April 23, 2023, 5:04pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment/312542/7 "2023-04-23T17:04:19Z")

</div>

@Syed_Hassan_Raahim Awesome! It was my pleasure to help you my friend!
