Skip to content
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: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (27, 2) + inhomogeneous part. #5

Open
yyara opened this issue Apr 14, 2023 · 1 comment

Comments

@yyara
Copy link

yyara commented Apr 14, 2023

Shuffling Randomly and Converting into Numpy Array for Faster Processing......

ValueError Traceback (most recent call last)
Cell In[22], line 3
1 print("Shuffling Randomly and Converting into Numpy Array for Faster Processing......")
2 random.shuffle(training)
----> 3 training = np.array(training)
5 print("Creating Train and Test Lists.....")
6 train_x = list(training[:,0])

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (27, 2) + inhomogeneous part.

@Systemcheck
Copy link

Systemcheck commented May 21, 2023

follow this site

the error occurs due to use of different datatypes in the numpy array elements, we can set the numpy array data type to object, it is a common data type that accepts all elements.

so set the datatype to object and all is fine.
np.array(array, dtype=object)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants