# Problem in C2\_W3\_Assignment

**URL:** <https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032>\
**Category:** Calculus for Machine Learning and Data Science\
**Tags:** lab-help, week-module-3\
**Created:** [November 24, 2024, 2:41pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032 "2024-11-24T14:41:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![saadbinwaqas](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@saadbinwaqas](https://community.deeplearning.ai/u/saadbinwaqas)\
**Post date:** [November 24, 2024, 2:41pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/1 "2024-11-24T14:41:30Z")

</div>

I am having an issue with the C2\_W3\_Assignment Neural Network with Two Layers for the Calculus for Machine Learning Course. I have passed all unit tests but get the following error for Exercise 3:

Failed test case: The output of the initialize\_parameters function has incorrect type…  
Expected:  
\<class ‘dict’\>,  
but got:  
\<class ‘NoneType’\>.

The variable ‘parameters’ is already defined as a dictionary and even the return type of print(type(parameters)) is \<class ‘dict’\>. Has anyone encountered or solved a similar error?

 ![image](https://global.discourse-cdn.com/dlai/original/3X/f/4/f4ff1e84eb1a9940b11c065458c4a2f1793cd00d.png)

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [November 24, 2024, 2:45pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/2 "2024-11-24T14:45:02Z")

</div>

Check if you are hardcoding anything in the solution!

---

<div class="post-metadata">

**Author:** ![saadbinwaqas](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@saadbinwaqas](https://community.deeplearning.ai/u/saadbinwaqas)\
**Post date:** [November 24, 2024, 3:05pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/3 "2024-11-24T15:05:13Z")

</div>

Thank you for the timely response. I have not hardcoded, just assigned the parameters according to the function requirements as given:

```
                W1 -- weight matrix of shape (n_h, n_x)
                b1 -- bias vector of shape (n_h, 1)
                W2 -- weight matrix of shape (n_y, n_h)
                b2 -- bias vector of shape (n_y, 1)

```

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 24, 2024, 3:28pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/4 "2024-11-24T15:28:50Z")

</div>

hi @saadbinwaqas

while adding the bias, you were suppose to use np.zeros((a,b)) to initialise a matrix of shape (a,b) with zeros. So when you don’t use that extra tuple, it might be throwing that nonetype error.

Also point to check, for weight np.random.randn need to be used.

another issue to check exercise 2 for layer size. check while writing codes for size of input layer and output layer, your code has used X.shape[0] or Y.shape[0]

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [November 24, 2024, 3:29pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/5 "2024-11-24T15:29:21Z")

</div>

Sorry I dont have access to this course maybe some other mentor can help with this further on!

---

<div class="post-metadata">

**Author:** ![saadbinwaqas](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@saadbinwaqas](https://community.deeplearning.ai/u/saadbinwaqas)\
**Post date:** [November 24, 2024, 3:53pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/6 "2024-11-24T15:53:41Z")

</div>

Thank you for the input. However, the program itself it not throwing an error, I have passed the unit test for all exercises. I have used two pairs of brackets for np.zeros, used np.random.randn for the weights, and 0 for the shape parameters of X and Y.

The problem comes in the grading. When I print the output of the function I get a dictionary and the type of the output is \<class ‘dict’\>. I added two lines of code before the unit test to confirm the output of the function.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/a/b/abfe560e807c1a9e23bf195f5398d851b0df93c2.png)

---

<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 24, 2024, 4:08pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/7 "2024-11-24T16:08:15Z")

</div>

Are you sure you clicked “Save” before you submitted to the grader? One possibility is that the grader is seeing an older version of your code.

---

<div class="post-metadata">

**Author:** ![saadbinwaqas](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@saadbinwaqas](https://community.deeplearning.ai/u/saadbinwaqas)\
**Post date:** [November 24, 2024, 4:20pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/8 "2024-11-24T16:20:25Z")

</div>

I pressed Ctrl + S manually and from the File menu. I had the problem since yesterday and have saved and re opened the file multiple times.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/7/2/72f11cb91d62d89d3bfc134d1f356d375bfad420.png)

This is the part of the function that returns parameters, and it was not supposed to be changed in anyway and I haven’t. The problem is still there.

I appreciate the fast responses and concern from everyone. Thank you!

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 24, 2024, 4:42pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/9 "2024-11-24T16:42:12Z")

</div>

hi @saadbinwaqas

Can you DM me the screenshots of grade cells. Click on my name and then message.

Regards  
DP

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [November 24, 2024, 5:07pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/10 "2024-11-24T17:07:55Z")

</div>

Your original error message implies that you may have left a “None” statement in the notebook when you sent it for grading.

Generally, you cannot grade an incomplete notebook.

---

<div class="post-metadata">

**Author:** ![saadbinwaqas](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@saadbinwaqas](https://community.deeplearning.ai/u/saadbinwaqas)\
**Post date:** [November 27, 2024, 2:42pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/11 "2024-11-27T14:42:42Z")

</div>

Solved: Opened a new copy of the notebook.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 2:52pm UTC](https://community.deeplearning.ai/t/problem-in-c2-w3-assignment/727032/12 "2024-11-27T14:52:54Z")

</div>

@saadbinwaqas

Just make sure to avoid such failed test errors avoid editing, adding or deleting anything beyond assigned markers ###YOUR CODE START HERE and ###YOUR CODE END HERE as your codes were perfectly right yet your initialise parameter for test cell where failing.

Regards  
DP
