Home > Enterprise >  TypeError: Cannot interpret '10000' as a data type
TypeError: Cannot interpret '10000' as a data type

Time:06-26

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

CodePudding user response:

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))
  • Related