parameters: (labels_dense, num_classes)
return_statement: return labels_one_hot
docstring: Convert class labels from scalars to one-hot vectors.
docstring_summary: Convert class labels from scalars to one-hot vectors.
docstring_tokens: Convert class labels from scalars to one - hot vectors .
function: def dense_to_one_hot(labels_dense, num_classes):
    """Convert class labels from scalars to one-hot vectors."""
    num_labels = labels_dense.shape[0]
    index_offset = numpy.arange(num_labels) * num_classes
    labels_one_hot = numpy.zeros((num_labels, num_classes))
    labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
    return labels_one_hot
function_tokens: def dense_to_one_hot ( labels_dense , num_classes ) : num_labels = labels_dense . shape [ 0 ] index_offset = numpy . arange ( num_labels ) * num_classes labels_one_hot = numpy . zeros ( ( num_labels , num_classes ) ) labels_one_hot . flat [ index_offset + labels_dense . ravel ( ) ] = 1 return labels_one_hot