I was using np.dot(w,X) method and python didn’t broadcast w. why is that?

It’s not a broadcasting problem: you haven’t gotten that far yet. The operation that is “throwing” there is the matrix multiply between w and X. w is a column vector of dimension 2 x 1 in this case. And X has dimensions 2 x 3. So doing the multiply of w dot X doesn’t work, right? They showed you what you need to do in the instructions. The actual formula for Z is:

Z = w^T \cdot X + b

So how would you write that in python?

Note that “broadcasting” does not apply for `np.dot`

or `np.matmul`

. It only applies for “elementwise” operations. Here’s a thread which discusses that in more detail.

thank you so much for your solution

I did it right and completed all the follwing exercies and passed all the tests but when I tried to put them all together in the last excercise but got this error

The dimensions were right when each single method was tested but somehow, it’s not correct here.

The bug must be in your `model`

code. Even if the subroutines are all correct, they can still throw errors if you pass them bad or mismatching arguments. The problem is that your w is the wrong shape, right? If there are 4 input features, then w should be 4 x 1. So why did it turn out wrong? Where is the shape of w determined?

I think it’s calculated right, maybe the problem with the X_train for some reason

*{moderator edit - solution code removed}*

The problem is not a bug in the initialize routine. The problem is that you passed the wrong value for dim when you called the initialize routine from the `model`

function.

yes it works thank you soo much