When to use np.dot

You’re right that it might be better if things were consistent, but that is Prof Ng’s choice. He uses the convention that standalone vectors are column vectors. So w in the Logistic Regression case is a column vector and that requires the transpose with the way he has defined the sample matrix X. But when it comes time to define the weights for a real NN, he defines them such that a transpose is no longer required. In other words, it’s the LR case that is the outlier here. If you wanted to make them consistent, the answer is not to add the transpose in the NN case: it’s to remove it in the LR case by making w a row vector.

Here’s another thread which discusses this in more detail.

1 Like