Problem in C2_W3_Assignment

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?

Check if you are hardcoding anything in the solution!

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)
1 Like

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]

1 Like

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

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.

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.

1 Like

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.

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!

hi @saadbinwaqas

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

Regards
DP

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.

Solved: Opened a new copy of the notebook.

2 Likes

@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