Let's say I have a row vector of the shape (1, 256). I want to transform it into a column vector of the shape (256, 1) instead. How would you do it in Numpy?
We can simply use the reshape functionality of numpy:
a=np.array([[1,2,3,4]]) a: array([[1, 2, 3, 4]]) a.shape (1,4) b=a.reshape(-1,1) b: array([[1], [2], [3], [4]]) b.shape (4,1)
2.1m questions
2.1m answers
60 comments
56.9k users