如何使用深度学习在python jupyter笔记本中解决此问题 [英] How to solve this problem in python jupyter notebook using deep learning
本文介绍了如何使用深度学习在python jupyter笔记本中解决此问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试跑步.但是会发生此错误
I am trying to run. But this error occurs
TypeError:int()参数必须是字符串,类似字节的对象或数字,而不是'NoneType'
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
这是代码
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/a/61244517/4442496 .如果您使用的是Windows计算机,这应该有所帮助
Refer to my answer in https://stackoverflow.com/a/61244517/4442496. This should help if you are using windows machine
这篇关于如何使用深度学习在python jupyter笔记本中解决此问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文