Gradient Checking Week 1 Assignment 3 Course 2

What do these lines execute?

parameters_values, _ = dictionary_to_vector(parameters)

grad = gradients_to_vector(gradients)
num_parameters = parameters_values.shape[0]

I tried to introspect the function using the gs_utils.py but wasn’t able to understand. If someone could help me out.

Thank you

gradients is a dictionary with keys as the grad name like dW, dZ etc. You can see this with gradients.keys()
gradients_to_vector converts this dictionary into a vector by arranging terms in a uniform fashion to help with vectorization.

Please follow a similar line of reasoning for dictionary_to_vector

# A good place to try to get this information is to look at the docstring for the functions.eg:
help(gradients_to_vector)

# to see how the dictionary items are arranged in a vector
from inspect import getsource

print(getsource(gradients_to_vector))
1 Like

any hint to solve this error will be appreciated:

Hint: \theta^{+}_i and \theta^{+} are different. Now please read the instructions again and check what is your mistake when calling forward_propagation_n function.