W3cubDocs

/TensorFlow 1.15

tf.keras.utils.to_categorical

View source on GitHub

Converts a class vector (integers) to binary class matrix.

E.g. for use with categorical_crossentropy.

Arguments
y class vector to be converted into a matrix (integers from 0 to num_classes).
num_classes total number of classes.
dtype The data type expected by the input. Default: 'float32'.
Returns
A binary matrix representation of the input. The classes axis is placed last.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/utils/to_categorical