keras np_utils()函数

from keras.utils import np_utils
N_CLASSES = 3
label = [0,0,0,1,1,1,2,2,2]
train_label = np_utils.to_categorical(label, N_CLASSES)

train_label
Out[21]:
array([[1., 0., 0.],
       [1., 0., 0.],
       [1., 0., 0.],
       [0., 1., 0.],
       [0., 1., 0.],
       [0., 1., 0.],
       [0., 0., 1.],
       [0., 0., 1.],
       [0., 0., 1.]], dtype=float32)

类似于tf.one_hot()

你可能感兴趣的:(T型牌坊)