I have a 28x28 pixel image as a numpy array and its shape is (28,28) using the np.array.shape function. I want the shape to be 784x1. In other words with a NxN matrix how do you convert it to a N^2x1. Using the flatten function i get almost what I'm looking for, the shape from flatten is (784,).
Asked
Active
Viewed 138 times
0
-
1`arr.reshape(784, 1)` should do it – hpaulj Feb 18 '20 at 19:59
-
Does this answer your question? [Reshape an array in NumPy](https://stackoverflow.com/questions/14476415/reshape-an-array-in-numpy) – mkrieger1 Feb 18 '20 at 20:03
-
Welcome to Stack Overflow! I recommend changing your subject so it reads more like a question. You may find that your questions are better received with a more descriptive subject. – Dave L Feb 18 '20 at 21:02
-
@hpaulj gave you the best answer. FYI, you can always add another axis to a flat array using `arr[:, np.newaxis]`. – Chris Mueller Feb 18 '20 at 21:09