How to convert numbers to one hot vectors?

I want to train a keras model and I use numpy to convert numbers to one hot vector. why Keras does not provide the implementation inside training process?

kerasnumpyone-hot
2 votesNN132.00
1 Answers
JW229.00
2

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/

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?