How to convert numbers to one hot vectors?
I want to train a Keras model and I use NumPy to convert numbers to a one-hot vector. why Keras does not provide the implementation inside the training process?
I want to train a Keras model and I use NumPy to convert numbers to a one-hot vector. why Keras does not provide the implementation inside the training process?
Because it's a seperated function and is not including in training process. Keras has a function called to_categorical
which converts numbers to one hot vector. here is an example
keras.utils.to_categorical(y, num_classes=None, dtype='float32')
where y is a vector of numbers which should be converted. Also take a look at the documentation of keras utils https://keras.io/utils/