Logistic_Regression_with_a_Neural_Network_mindset Exercise 8

Hello I am really confused about exercise 8.

{moderator edit: code removed

I am getting an error because I am attempting to dot vectors of wrong dimension. Here is my earlier code from propagate function which passed the tests:

{moderator edit: code removed

So A is dimension (4, 1), and Y is dimension (7, 1). I can’t flip dimensions of A so this dot product does not work.

Did you try transposing ‘A’ in the cost calculation?

Why [1] here?

The problem is that screws up the exercise for the propagate function-- the dimensions don’t match

Should not need a transpose here.

I think you transposed the wrong variable.

Bc shape is a matric 2x2, w is a vector

Why not?

Because its within propagate function, and if i try to alter in there I ruin the other exercise for propagate function

Don’t rely on that in all cases. Your code will be tested with several different sizes of matrix - not all of them are square.

Your implementation of A is wrong in the first place. Here’s the math formula for the code you wrote:

A = sigmoid(X^T \cdot w + b)

Please have a look at the formulas in the instructions. That’s not what they say, right?

Don’t modify the variable, just transpose it where you’re using it in np.dot().

Also, I’ll edit the thread to remove the code from the OP, because posting your code on the forum isn’t allowed by the Code of Conduct.

Generally, a mentor will give you specific instructions if we need to see your code.

Easy enough to clean it up afterward.