Course2 week 1 Assignment 4

alueError Traceback (most recent call last)
in
3 cost, cache = forward_propagation_n(X, Y, parameters)
4 gradients = backward_propagation_n(X, Y, cache)
----> 5 difference = gradient_check_n(parameters, gradients, X, Y, 1e-7, True)
6 expected_values = [0.2850931567761623, 1.1890913024229996e-07]
7 assert not(type(difference) == np.ndarray), “You are not using np.linalg.norm for numerator or denominator”

in gradient_check_n(parameters, gradients, X, Y, epsilon, print_msg)
36 # YOUR CODE STARTS HERE
37 theta_plus = np.copy(parameters_values)
—> 38 theta_plus[i] = np.add( theta_plus , epsilon)
39 J_plus[i], _ = forward_propagation_n(x, y, vector_to_dictionary( theta_plus[i]))
40

ValueError: could not broadcast input array from shape (47,1) into shape (1)

Please why am I getting this error?

I have seen my error now.

1 Like

I had the same error, the problem was passing the entire theta_plus vector, instead of theta_plus[i]