C2W1 Exercise 3 cannot index ndarray A_in

It seems we cannot even use A_in[i, :] ( or b[0, 1] ) in this exercise.
I know how to do it with the matrix multiplication method, but just wondering why it shows that “IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed” even if A_in is actually a 2D array.

Thanks in advance for any hint!

Hello @HelloML,

Would you please also share the full error traceback besides the error message?

Cheers,
Raymond

{assignment code removed by mentor as we can’t share it here}


Hi Raymond,
Thanks for replying! I just uploaded the screenshots. Both b[0, 1] and d A_in[0, :] are not working here.

Hello @HelloML,

Let’s look at this line from your screenshot:

image

Apparently the b there is a 1D-array.

The error does not indicate whether it’s a probem of b, or of A_in, or of both, but apparently b is a source of the problem.

Raymond


It seems this is a bug?
Since in the cell below the coding cell(screenshot), both A_in and b are 2-D even if they are vectors, i.e. (1, n); however, in the test cell, A_in and b becomes 1-D (n, ), which is 1-D.

Hello @HelloML,

Thank you! I will communicate about this with the course team. Besides b, is there any other problem?

Cheers,
Raymond

That’s the only problem, i.e. (n, ) and (1, n) .
Thanks!

Got it!

Cheers,
Raymond