The issue here seems to be with the shape/dimension of one of the variables. I’d suggest that you print the shape of m, X, A, and Y. That way you can see where the shape issues originated.

Study your traceback (i.e. error message). You are throwing a ValueError exception saying that your expression for dw is violating the rules of matrix algebra. As you can see in the test case, X is set up as a 2 \times 3 dimensional matrix; Y is 1 \times 3, but A-Y is transposed so the second factor is 1 \times 3. You are using the asterisk operator which performs element-by-element matrix multiplication. That operation requires that the two factor matrices have exactly the same dimensions, so no good.

You want ordinary matrix multiplication here, which requires that the inner dimensions agree. In this case, 3 = 3, so good. The product will be a 2 \times 1 matrix (determined by the outer dimensions of the factor matrices. The np.dot() function performs matrix multiplication, not *. [BTW, you can also use the @ operator for matrix multiplication, but you will not see that one applied in the DLS.]

At least a couple of things may be at the root of your problem. Either you do not have a grasp on basic matrix operations, or you have Python syntax issues. Try to remediate either, or both.

You may have other problems, but let’s start with that which is revealed by the traceback.

Note well: You are not allowed to post your solution code in Discourse or any other public forum. pursuant to the Coursera honor code (that you signed off on.) In other words, it is cheating. Suppose that you were in a lecture hall and you dropped off your solutions to a friend on the way out. Even if they were wrong, it’s bad behavior and will run afoul of the proctors.

Thank you so much, that solved it (the matrix multiplication) instead of element-wise multiplication!

I have no intention of breaking the honor code. Sorry for that, you are 100% right. For the future, what is the proper way to let the mentor know of my solution (in order to help them find my mistake easily), without revealing it to the other sudents? The paralel to the lecture hall situation would be approaching the teacher. Is there a way to contact a mentor privately?

The accepted practice is to post the (complete) traceback. Typically some of your code will show up in that, but that’s OK.

Although, you can direct message a mentor (click on their photo or icon), it is better to post in the public Discourse forum so that all may benefit from the discussion. It also creates a useful archive entry to enhance the value of Discourses’ search capabilities.