python - 如何在 python jupyter notebook 中将标签从整数转换为向量?
问题描述
我正在尝试应用正确的代码,但总是给我一个错误。这里是代码
trainY =keras.utils.to_categorical(trainY, num_classes=2, dtype='float32')
testY = keras.utils.to_categorical(testY, num_classes=2, dtype='float32')
它会产生一个错误,即
TypeError Traceback (most recent call last)
<ipython-input-23-dea4d664a742> 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')
~\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'
帮助我。谢谢。
解决方案
推荐阅读
- java - 如何在没有 Eclipse 的情况下使用 WebSphere 8.5.5
- c# - 在 button1 上单击创建变量,在 button2 上单击使用在 button1 | 中创建的变量。C# WPF
- node.js - Axios - Cheerio 如何等待所有信息从服务器加载
- swift - 您如何根据用户输入发送通知?迅速
- symfony5 - 如何解决 Symfony 5.1.5 上的 Lexit JWT 401 错误“由于系统问题无法处理身份验证请求”
- javascript - 在服务器 jquery.min.js:2 POST https://company.co.in/Home/tbl 404 上出现错误(未找到)
- r - 变异数据框以检查两个数据框之间的数据是否重复
- javascript - JS:动态添加链接到某个类的所有元素
- typescript - 属性 'subscriptionClient' 是私有的,只能在类 'WebSocketLink'.ts(2341) 中访问
- reactjs - 如何在 ag 网格中添加动作列,其中每行都有编辑/删除按钮?