For example, given a numpy array of dimensions (132, 82, 100), the resultant dimensions would be (132, 8200)
Asked
Active
Viewed 3,413 times
0
-
Just create a new array with the dimensions you want and insert the values as you would like them. – Almog-at-Nailo Jun 13 '21 at 12:32
-
1have you tried the 'reshape' method or the 'view' funciton? – yann ziselman Jun 13 '21 at 12:33
-
2Does this answer your question? [How to flatten only some dimensions of a numpy array](https://stackoverflow.com/questions/18757742/how-to-flatten-only-some-dimensions-of-a-numpy-array) – yann ziselman Jun 13 '21 at 12:34
1 Answers
1
You can use reshape() function to change shape of the array. Using -1 as a parameter to reshape tells numpy to infer the dimension there.
arr = np.zeros((132, 82, 100))
arr = arr.reshape(*arr.shape[:-2], -1)
print(arr.shape)
# Out: (132, 8200)

yann ziselman
- 1,952
- 5
- 21

Shubham
- 1,310
- 4
- 13