How to solve this problem in python jupyter notebook using deep learning

梦想与她 提交于 2020-01-11 14:33:34

问题


I am trying to run. But this error occurs

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Here is code

data = np.asarray(data, dtype="float") / 255.0
labels = np.array(labels)
print("Success")
# partition the data into training and testing splits using 75% of
# the data for training and the remaining 25% for testing
(trainX, testX, trainY, testY) = train_test_split(data,
    labels, test_size=0.25, random_state=42)

#this is run successfully but when this part of code run then always error will occur

# convert the labels from integers to vectors
trainY =keras.utils.to_categorical(trainY, num_classes=2, dtype='float32')
testY = keras.utils.to_categorical(testY, num_classes=2, dtype='float32')
print(type(trainY))
print(type(testY))

and this type of error is occur

<ipython-input-12-a1259f490078> in <module>
      1 # convert the labels from integers to vectors
----> 2 trainY =keras.utils.to_categorical(trainY, num_classes=2, dtype='float32')
      3 testY = keras.utils.to_categorical(testY, num_classes=2, dtype='float32')
      4 print(type(trainY))
      5 print(type(testY))

~\Anaconda3\lib\site-packages\keras\utils\np_utils.py in to_categorical(y, num_classes, dtype)
     41     """
     42 
---> 43     y = np.array(y, dtype='int')
     44     input_shape = y.shape
     45     if input_shape and input_shape[-1] == 1 and len(input_shape) > 1:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

来源:https://stackoverflow.com/questions/59589434/how-to-solve-this-problem-in-python-jupyter-notebook-using-deep-learning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!