HI i am stuck with assignment problem
{moderator edit - solution code removed}
HI i am stuck with assignment problem
{moderator edit - solution code removed}
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
‘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.
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.
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.
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.
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
did it nothing happened
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.
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.
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 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.
sir i have solved this assignment by getting clean copy will do next thank you