Week 2 Exercise 8

I got this error when working on the model exercise and am unsure of how to fix it.


I also got another error earlier, and I might have fixed it improperly, resulting in this issue, so here’s the error.


Sorry, it was this error: I accidentally uploaded the same screenshot twice.

could you specify how you fixed the second error?.
for that just check wether you are using the dimensions for initialisation as X_train.shape[0] in initialise_with_zeroes

Here’s how I fixed the second error:
A = sigmoid(np.vdot(X, train_set_x.T)+b)

There is a lot to worry about here. For starters, train_set_x is a global variable, right? It’s a big mistake to reference global variables in the body of your functions: you should only be referencing the parameters that are passed in and local variables that you define within the scope of the function. Then why are you dotting to different versions of the X input data matrix? Why would that make any sense? And how you do you get any 4D arrays as input to any of the functions here? We took care of that in the “flattening” section early in the notebook, right? That’s the last we should be seeing of anything shaped 209 x 64 x 64 x 3.

It looks like your code in propagate is actually correct, but the problem is all the data that you passed down to it is wrong. For starters the w should have the shape 12288 x 1, not 209 x 1, right? I think the problem there is that your X_train parameter is the wrong shape. See my comment about the flattening logic above. Then the shape of X in propagate should be 12288 x 209 for the training data. Why is it 209 x 64 x 64 x 3? You must have modified the test call that invokes model to change which variables are being passed.

Also we never have any need to use np.vdot. Just use np.dot.

1 Like