def _to_categorical(y, num_classes=None, reshape=True):
    '\n    # copy of keras.utils.np_utils.to_categorical, but with a boolean matrix instead of float\n\n    Converts a class vector (integers) to binary class matrix.\n\n    E.g. for use with categorical_crossentropy.\n\n    # Arguments\n        y: class vector to be converted into a matrix\n            (integers from 0 to num_classes).\n        num_classes: total number of classes.\n\n    # Returns\n        A binary matrix representation of the input.\n    '
    oshape = y.shape
    y = np.array(y, dtype='int').ravel()
    if (not num_classes):
        num_classes = (np.max(y) + 1)
    n = y.shape[0]
    categorical = np.zeros((n, num_classes), bool)
    categorical[(np.arange(n), y)] = 1
    if reshape:
        categorical = np.reshape(categorical, [*oshape, num_classes])
    return categorical
# copy of keras.utils.np_utils.to_categorical, but with a boolean matrix instead of float

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.

# Returns
    A binary matrix representation of the input.
def _to_categorical(y, num_classes=None, reshape=True):
    '\n    # copy of keras.utils.np_utils.to_categorical, but with a boolean matrix instead of float\n\n    Converts a class vector (integers) to binary class matrix.\n\n    E.g. for use with categorical_crossentropy.\n\n    # Arguments\n        y: class vector to be converted into a matrix\n            (integers from 0 to num_classes).\n        num_classes: total number of classes.\n\n    # Returns\n        A binary matrix representation of the input.\n    '
    oshape = y.shape
    y = np.array(y, dtype='int').ravel()
    if (not num_classes):
        num_classes = (np.max(y) + 1)
    n = y.shape[0]
    categorical = np.zeros((n, num_classes), bool)
    categorical[(np.arange(n), y)] = 1
    if reshape:
        categorical = np.reshape(categorical, [*oshape, num_classes])
    return categorical