Answers for "numpy flatten to 2d"

1

flatten a 2d array python

arr_2d = [[1, 2, 3], [4, 5, 6]]
arr_1d = [el for arr in arr_2d for el in arr]
print(arr_1d) # [1, 2, 3, 4, 5, 6]
Posted by: Guest on May-18-2021
1

flatten image python numpy

x_data = np.array( [np.array(cv2.imread(imagePath[i])) for i in range(len(imagePath))] )

  pixels = x_data.flatten().reshape(1000, 12288)
  print pixels.shape
Posted by: Guest on September-10-2020
0

numpy flatten along two axes

>>> arr = numpy.zeros((50,100,25))
>>> arr.shape
# (50, 100, 25)

>>> new_arr = arr.reshape(5000,25)
>>> new_arr.shape   
# (5000, 25)
Posted by: Guest on June-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language