日理万机的杨总 2022-08-05 22:24 采纳率: 25%
浏览 14

这里面就4种标签,为什么里面说8超出了范围

问题遇到的现象和发生背景

index 8 is out of bounds for axis 1 with size 4

问题相关代码,请勿粘贴截图

print(pd.value_counts(y_train))
class_num = len(np.unique(y_train))
print(class_num)
#onehot编码
y_train = to_categorical(y=y_train, num_classes=class_num)
print(y_train.shape)

运行结果及报错内容

0.0 2429
1.0 2429
3.0 2429
8.0 2429
dtype: int64
4
IndexError: index 8 is out of bounds for axis 1 with size 4

我的解答思路和尝试过的方法

这里面就4种标签,为什么里面说8超出了范围

我想要达到的结果

求解决,谢谢

  • 写回答

1条回答 默认 最新

  • 亖夕 新星创作者: python技术领域 2022-08-05 22:31
    关注

    代码再贴全一些

    评论

报告相同问题?

问题事件

  • 创建了问题 8月5日