user3668129
user3668129

Reputation: 4820

ValueError: could not broadcast input array from shape (150528,1) into shape (150528)

I'm trying to copy array to matrix (to fill row) as follows:

image = cv2.imread(file)    
feature = image.reshape((IMAGE_LEN, -1))
features_matrix[0] = np.copy(feature[0:])

but getting the following error:

ValueError: could not broadcast input array from shape (150528,1) into shape (150528)

the features_matrix was build with the right size (np.zeros((NUM_OF_FILES_PER_LABEL,IMAGE_LEN))

and feature[0:] (or feature[0::]) fit to this size.

print (feature.shape) gives (150528,1)

so what is wrong and how can I fix it ?

(I'm using python 3.7)

Upvotes: 0

Views: 102

Answers (1)

Alexis Pister
Alexis Pister

Reputation: 499

Try image.reshape((IMAGE_LEN))

Upvotes: 1

Related Questions