The w and dw values here should be column vectors of the same dimension. Note that it is the number of rows not columns of the training and test input matrices that give you the number of “features”, which is the number of elements in w. The number of columns is the number of samples in each set and there is no need for those to agree between the training and test data.

I added some print statements to my code and here are the dimensions and some of the results that I see when I run the test cell for exercise 8:

type(X_train) <class 'numpy.ndarray'>
X_train.shape (4, 7)
X_test.shape (4, 3)
Y_test.shape (3,)
num_iterations 50 learning_rate 0.01
pred train [[1. 1. 0. 1. 0. 0. 1.]]
pred test [[1. 1. 0.]]
w [[ 0.08639757]
[-0.08231268]
[-0.11798927]
[ 0.12866053]]
b -0.039832360948163205
All tests passed!

You’ll notice that the number 28 does not occur anywhere there so there is some fundamental issue in how you are interpreting what needs to happen here. The number of “features” is 4 for this particular set of input data.

Of course the other important point to make here is that all the code we are writing is intended to be “general” in the sense that it will work with inputs of any size. Meaning that the code needs to derive any dimensions from the actual input data, not by “hard-coding” anything.

Indeed. It looks like you must have been multiplying the row and column dimensions in order to get 28 and 12. Glad to hear you were able to sort it out.