Week 1: Gradient Checking's Last exercise error

I keep getting this error while running the test for the last exercise:

I don’t understand what I’m doing wrong. Here is my code below;

[code removed for Honor Code]

Hi @stevenkolawole,

Looking at the error message and your code seems that the function vector_to_dictionary is expecting a vector and you are providing only one vaue, so there’s no way to transform that lonely value to the shape (5,4).

Please try to check the contents of the gc_utils.py where the function is implemented, and notice that is expecting all the parameters and not just the one you just computed.

Hope that helps.

P.D. I’m going to remove your solution for the sake of the Honor Code.


Hi there,

Happy New Year.

I have the exact same issue. I have looked at gc_utils.py and the vector_to_dictionary function does indeed look exactly like in the Traceback (i.e “parameters[“W1”] = theta[: 20].reshape((5, 4))”)

It appears that the only way to change this is by changing the partial vector expression in the function itself.
I tried changing the line of code to:
" parameters[“W1”] = theta[0: 20].reshape((5, 4))”
It throws:
“cannot reshape array of size 1 into shape (5,4)”
As a sanity check I tried:
"parameters[“W1”] = theta[1: 20].reshape((5, 4))”
It throws:
“cannot reshape array of size 0 into shape (5,4)”

I have carefully returned gc_utils.py to its original code, as I fear I may be heading too far off piste.
Am I ?
Is there some other place to provide “all the parameters” that the function is expecting outside of

Many thanks

I had the same problem, You need to understand that you have to pass the whole vector theta (either minus or plus) to the forward propagation function, this error occurs when passing a single unit of vector theta( again either minus or plus).