-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: cannot reshape array of size 16950 into shape (16800,) #1
Comments
To resolve this issue, you need to ensure that the total number of elements in the array matches the total number of elements in the desired shape. In this specific case, it seems like you want to reshape an array with 16950 elements into a shape of (16800,). Since these numbers don't match, you will need to reshape it into a shape that has the same number of elements (in this case, 16950). You can reshape the array into a shape of (16950,) like this: img = img.reshape(16950) Make sure that the new shape you specify matches the total number of elements in the array you are trying to reshape. |
# sure you cannot directly (16800,) to (16950,) due 16800 !=16950 you can reshape it to (16800,1), to (1, 16800)
#(numpy.tranpose()) , in machine learning you can reshape that through padding slicing, cliping , ....(arrays represents data #such images , text etc)
import numpy as np
# convert it an array
arr = np.arange(16800)
# Calculate padding amount
padding_amount = 16950 - arr.shape[0]
# Pad with zeros at the end
padded_arr = np.pad(arr, (0, padding_amount), mode='constant', constant_values=0)
# Reshape to the desired shape
reshaped_arr = padded_arr.reshape(16950,)
print(reshaped_arr.shape) # Output: (16950,)
#you can use other libraries opencv, keras, tensorflow, pytorch |
use the below code in model.py to resolve this issuefrom sklearn.svm import LinearSVC class Model:
|
I am getting error at reshaping the image:
in model.py
img = img.reshape(16800)
^^^^^^^^^^^^^^^^^^
ValueError: cannot reshape array of size 16950 into shape (16800,)
The text was updated successfully, but these errors were encountered: