keras np_utils() function

Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission. https://blog.csdn.net/Arctic_Beacon/article/details/85292994
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)

Similar to tf.one_hot()