Getting error: Cannot reshape array of size 122304 into shape (52,28,28)

后端 未结 2 1311
半阙折子戏
半阙折子戏 2021-01-18 02:08

I\'m trying to reshape a numpy array as:

data3 = data3.reshape((data3.shape[0], 28, 28))

where data3 is:

[[54          


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 02:31

    First, your input image's number of elements should match the number of elements in the desired feature vector.

    Assuming the above is satisfied, the below should work:

    # Reading all the images to a one numpy array. Paths of the images are in the imagePaths
    data = np.array([np.array(cv2.imread(imagePaths[i])) for i in range(len(imagePaths))])
    
    # This will contain the an array of feature vectors of the images
    features = data.flatten().reshape(1, 784)
    

提交回复
热议问题