# DLS course2 week 1 Initialization problem

**URL:** <https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306>\
**Category:** Improving Deep Neural Networks: Hyperparameter tun\
**Tags:** coursera-platform\
**Created:** [February 4, 2023, 3:40pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306 "2023-02-04T15:40:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [February 4, 2023, 3:40pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/1 "2023-02-04T15:40:48Z")

</div>

HI i am stuck with assignment problem

_{moderator edit - solution code removed}_

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [February 4, 2023, 3:55pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/2 "2023-02-04T15:55:03Z")

</div>

Hi @Sudipta_Mukherjee1 ,

Please don’t post your solution (notebook file) in this public forum - only if a mentor requests it via direct message. Please remove it.

It is best practice to post the error you are getting.

Now, I see that your problem is in the “initialize\_parameters\_zeros” cell.

Please make sure that you are following the instructions. In this case you are asked to initialize all parameters in zeros. Are you initializing all parameters in zeroes? please check your implementation for the W params.

Thanks,

Juan

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [February 6, 2023, 2:07pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/3 "2023-02-06T14:07:45Z")

</div>

![Screenshot (76)](https://global.discourse-cdn.com/dlai/original/3X/0/1/01cd6bac8cbe44f611d73e2c2392097be2fe9136.png)  
now it is showing np name error please help

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [February 6, 2023, 2:11pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/4 "2023-02-06T14:11:09Z")

</div>

‘np’ is the alias given to numpy, a library used in this notebook.

If you look at the very first code cell you will see one of the instructions reading:

import numpy as np

This error means that np is not defined, which means that the cell has not been executed in the current session.

Please execute the code cells from top up until your current cell.

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [February 6, 2023, 2:28pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/5 "2023-02-06T14:28:01Z")

</div>

now it is showing another problem i have run all shells

 ![Screenshot (79)](https://global.discourse-cdn.com/dlai/original/3X/a/a/aa1ae0a23f93793b4a33dd2a6c4cfc83bdb13ba1.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:** [February 6, 2023, 3:36pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/6 "2023-02-06T15:36:37Z")

</div>

Notice that there is no “return” statement in your function. That is why you get that “NoneType” error in the test cell: your function does not actually return anything. That was part of the template code and there should have been no reason to remove it. If it’s not obvious where to add the return, then please get a clean copy of the notebook and compare. There’s a topic about how to do that on the [DLS FAQ Thread.](https://community.deeplearning.ai/t/faq-frequently-asked-questions-for-all-dls-courses/74)

Also note that is not the only problem with the code in that function. Please read the instructions and the “docstring” again about what the shape of W^{[l]} should be.

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [February 7, 2023, 1:26pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/7 "2023-02-07T13:26:49Z")

</div>

Building on what @paulinpaloalto clearly explains, assuming that you have not modified the original cells below this one, please check the next exercise in section 5 - Random Initialization, name of the cell’s function is: initialize\_parameters\_random.

See how in the given code the function, which is very similar to the one you are working on, ends with this sentence:

“return parameters”

And very important: see how this instruction is aligned with the “for” loop.

Now compare it with your current cell. Can you see that the function is not the same? it doesn’t have the “return parameters”. In your case you may have removed the return accidentally.

This “Return” is the reason of being of functions: they need to do something and return something.

Moving forward, please keep this in mind:

Do not change anything that is outside of the prompts ### BEGIN SOLUTION and ### END SOLUTION

And as pointed by Paul, you may want to get a fresh version of the notebook by following the instructions provided.

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [March 23, 2023, 2:16pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/8 "2023-03-23T14:16:37Z")

</div>

![Screenshot (63)](https://global.discourse-cdn.com/dlai/original/3X/e/a/ea69970ab57537f7b01a6ba46530f4464a7775a4.png)  
 ![Screenshot (64)](https://global.discourse-cdn.com/dlai/original/3X/d/4/d4c301ccbffee5b0ab06d76fd0c73b2d6126d46d.png)  
now it is showing another error please help

---

<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:** [March 23, 2023, 2:21pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/9 "2023-03-23T14:21:34Z")

</div>

Hi @Sudipta_Mukherjee1 ,

Refresh the kernel and rerun the code should help. From the menu bar on top of your notebook, click:

Kernel → restart  
Cell → run all above

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [March 23, 2023, 2:24pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/10 "2023-03-23T14:24:51Z")

</div>

did it nothing happened

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [March 23, 2023, 2:34pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/11 "2023-03-23T14:34:39Z")

</div>

![Screenshot (66)](https://global.discourse-cdn.com/dlai/original/3X/6/5/650ed38bc8f679be2ba5c4e9f1240e638173383b.png)  
this error is occuring

---

<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:** [March 23, 2023, 2:40pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/12 "2023-03-23T14:40:14Z")

</div>

The problem is that `parameters` on that line is the wrong data type. It should be a dictionary, but it is `None`, so how did that happen? Print the type right before the line that throws:

`print(f"type(parameters) = {type(parameters}")`

That value is set by the return value from your `model` function. So that says that your `model` function must be broken. Did you change the indentation on the return statement? Indentation is a critical part of the syntax of python. If you “outdent” the return statement, then it is no longer part of the body of the function. But the model code was just given to you and there was no need to modify it, right? Maybe you should get a clean copy of the notebook and copy over your code.

---

<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:** [March 23, 2023, 2:52pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/13 "2023-03-23T14:52:47Z")

</div>

Hi @Sudipta_Mukherjee1 ,

Put a print statement before the ‘for’ loop in the model() function to print out the content of the variable ‘parameters’. That will show if those initialization functions are working correctly.

---

<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:** [March 23, 2023, 2:57pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/14 "2023-03-23T14:57:11Z")

</div>

Sudipta DM’ed me the notebook. The `return` statement has simply been deleted from the `model` function, which is why that error occurs. There should have been no need to modify that code at all, so presumably this was some sort of accident. The best thing to do would be to [get a clean copy of the notebook](https://community.deeplearning.ai/t/how-to-get-a-clean-copy-of-an-assignment-notebook/73) and then “copy/paste” your code from only the “YOUR CODE HERE” sections over to the clean copy, in case there is other similar damage to the parts that didn’t need to be changed.

---

<div class="post-metadata">

**Author:** ![Sudipta\_Mukherjee1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Sudipta\_Mukherjee1](https://community.deeplearning.ai/u/Sudipta_Mukherjee1)\
**Post date:** [March 23, 2023, 3:35pm UTC](https://community.deeplearning.ai/t/dls-course2-week-1-initialization-problem/268306/15 "2023-03-23T15:35:54Z")

</div>

sir i have solved this assignment by getting clean copy will do next thank you
