Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings


TensorFlow 1 version View source on GitHub

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

    y, num_classes=None, dtype='float32'

Used in the notebooks

Used in the guide

E.g. for use with categorical_crossentropy.


  • 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'.


A binary matrix representation of the input. The classes axis is placed last.