【发布时间】:2018-01-31 23:03:24
【问题描述】:
labels = np.array([['positive'],['negative'],['negative'],['positive']])
# output from pandas is similar to the above
values = (labels=='positive').astype(np.int_)
to_categorical(values,2)
输出:
array([[ 1., 1.],
[ 1., 1.],
[ 1., 1.],
[ 1., 1.]])
如果我删除每个元素的内部列表,它似乎工作得很好
labels = np.array([['positive'],['negative'],['negative'],['positive']])
values = (labels=='positive').astype(np.int_)
to_categorical(values.T[0],2)
输出:
array([[ 0., 1.],
[ 1., 0.],
[ 1., 0.],
[ 0., 1.]])
为什么会这样?我正在关注一些教程,但即使对于数组数组,它们似乎也得到了正确的输出。是否最近升级为这种行为方式?
我在py362上使用tflearn (0.3.2)
【问题讨论】:
标签: python numpy tflearn one-hot-encoding