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?

2 votesNN160.00
1 Answers

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

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