Problems with course 1 week 4 assignment

I have been having problems with exercise 3 for weeks now. I am failing to get the correct shape.
Wrong shape of vector X1.
Expected: (5, 1).
Got: (5, 5).
5 Tests passed
1 Tests failed

Hi there,

If we consider the failed-testcase prompt, maybe there is a problem in the way you’re performing the matrix multiplication. That’s why, after the multiplication, your X1 became a matrix with shape (5, 5).

  • Why your other testcases are giving correct result?
  • One of the possiblities - Python’s default sum function automatically sums about axis 0.

If you’re still unsure and can’t find a way around, send me a private message ^{1}. I’ll try to help you.

Happy learning!


^{1} : Not here, because you mustn’t post your code snippets (with possible solutions) publicly according to the Honor code.

Good day
Thanks for the help, but i still cannot figure it out

Hello, @Eunice_Mpofu just to add a little on what @AeryB has said.

From the error message, It suggests that the vector X1 has the wrong shape. The function expected a vector of shape (5,1) but received a vector of shape (5,5). This means that the function is getting a matrix instead of a column vector.

I do think to fix this error, you can reshape the input matrix X1 into a column vector of shape (5,1) before passing it to the function.

You can try X1.reshape(5, 1)

Happy Learning
Isaak

1 Like