If x has shape (5,), what is the shape of x[:, np.newaxis]?
Correct answer
B. (5, 1)
17 views
B. (5, 1)
17 views
np.newaxis inserts a dimension of length 1, turning x into a column vector. This is often done to enable broadcasting against a row vector.
Asked in: Data Science Interviews
Not sure why the answer is B? Ask here and get an explanation.