Hello,

I am working on my week two assignment of neural network and got stuck in the last stage. I have implemented the codes for the model but it keeps throwing the error: ValueError: shapes (1,4) and (2,3) not aligned: 4 (dim 1) != 2 (dim 0)

Please share your full error.

Can I include the code?

I wanted to complete the logistic regression model to compute Y_predict_test and Y_predict_train. I wrote the code but seems like the matrix multiplication is an issue.

You cannot include the code. Only share your full error.

It looks like your X matrix is the wrong shape: it doesn’t match the shape of the w vector. So you must have passed the wrong argument to the initialize routine. A common mistake is to reference a global variable instead of referencing the parameters that were actually passed to the `model`

function.

```
A = sigmoid(np.dot(w.T, X) +b)
```

ValueError: shapes (1,4) and (1,3) not aligned: 4 (dim 1) != 1 (dim 0)

I get the same error

Which function are you working on here? If it’s the model function, I added some print statements in my code to show the shapes of the variables and here’s what I see when I run the `model_test`

cell:

```
type(X_train) <class 'numpy.ndarray'>
X_train.shape (4, 7)
X_test.shape (4, 3)
Y_test.shape (1, 3)
before optimize w.shape (4, 1)
num_iterations 50 learning_rate 0.01
at return in optimize w.shape (4, 1)
in model before predict call w.shape (4, 1)
predictions = [[1. 1. 0. 1. 0. 0. 1.]]
predictions = [[1. 1. 0.]]
All tests passed!
```

So it looks like the shape of your w value is correct, but somehow the X is the wrong shape. So how could that happen?