Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: Cannot interpret '10000' as a data type

I am writing the following code for a deep learning program in python but it is repeatedly giving me errors.

import numpy as np
def vectorize_sequences(sequences,dimension=10000):
results=np.zeros((len(sequences)),dimension)
for i,sequence in enumerate(sequences):
results[i,sequence]=1
return results

error-TypeError: Cannot interpret ‘10000’ as a data type

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to change the line results=np.zeros((len(sequences)),dimension). Here dimension is being passed as the second argument, which is supposed to be the datatype that the zeros are stored as. Change it to:

results = np.zeros((len(sequences), dimension))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading