#NEWLINE# def _dense_to_one_hot( labels_dense , num_classes ) : #NEWLINE# #INDENT# 'Convert class labels from scalars to one-hot vectors.' #NEWLINE# num_labels = labels_dense . shape [ 0 ] #NEWLINE# index_offset = ( np . arange ( num_labels ) * num_classes ) #NEWLINE# labels_one_hot = np . zeros ( ( num_labels , num_classes ) ) #NEWLINE# labels_one_hot . flat [ ( index_offset + labels_dense . ravel ( ) ) ] = 1 #NEWLINE# print ( num_labels [ 0 ] ) #NEWLINE# return labels_one_hot