【发布时间】:2021-06-03 08:48:38
【问题描述】:
我正在尝试从头开始构建多分类神经网络,但 One_hot 函数不起作用,您能帮我解决吗?
def one_hot(Y):
one_hot_y=np.zeros((Y.size,Y.max() +1))
one_hot_y[np.arange(Y.size), Y] = 1
one_hot_y = one_hot_y.T
return one_hot_y
这是我在运行神经网络函数时遇到的错误类型
【问题讨论】:
-
我猜
Y包含字符串。Y.max() + 1应该是什么? -
显然
Y.max()是一个字符串 -
试试
int(Y.max()) + 1
标签: python machine-learning neural-network multiclass-classification