爲什麼Keras to_categorical在[1,-1]和[2,-2]上表現不同?Keras np_utils.to_categorical行爲不同
y = [1, -1, -1]
y_ = np_utils.to_categorical(y)
array([[ 0., 1.],
[ 0., 1.],
[ 0., 1.]])
y = [2, -2, -2]
y_ = np_utils.to_categorical(y)
array([[ 0., 0., 1.],
[ 0., 1., 0.],
[ 0., 1., 0.]])
它爲什麼會表現相同的方式? –
我想to_categorical應該將y數據集轉換爲one-hot-vector數據集。 [1]和[-1]應具有不同的編碼值。就像[2] ==> [0,0,1]和[-2] ===> [0,1,0]。 –