Course 1 Week 2 Assignment 2 Exercise 8

I passed all the tests and yet it is giving me this error.

Hi @inam,

Could you check the shape of W and the shape of X?

Are they what you had expected them to be?

They are different. I do know what I am doing wrong here but I dont know where it is


An easy way to debug where the mistake is, is to print the shapes of the different variables at the different stages.
Looking at the error code, I can tell you that you need to look into the propagate function!

Hope this helps!

Just because the error is thrown in propagate does not mean that is where the error is. That routine just takes w and X as inputs and the shapes don’t match. So the bug is that you passed propagate a w which is the wrong shape. So look at the logic of your model function: where is the shape of w determined? It is by the dimension that you pass to the initialize routine, right? Look at what you passed:

X_train.shape[1] * X_train.shape[1] * 3

That is the number of samples (columns of X_train) squared times 3. What does that have to do with anything? The number of elements of w should equal the number of rows of X_train, right? That is the number of “features”.

It was like a random thing i tired when i couldnt think of anything else

So I am done with the assignment. I wanted to ask should I be able to write my own neural network by this point? Or should I practice more?

Do you mean the Logistic Regression assignment in Week 2? If so, then my recommendation is to wait until you finish Course 1. In Week 4, you learn how to build fully general “feed forward” neural nets. Once you finish Week 4, you have what you need to build your own general Deep Neural Net. Of course there are plenty of other useful things to learn in the rest of the Courses, e.g. more sophisticated types of networks (Convolutional Nets in Course 4).

sure sir. thank you for the advice