#NEWLINE# def string_to_one_hot( string , maxchar ) : #NEWLINE# #INDENT# 'Converts an ASCII string to a one-of-k encoding.' #NEWLINE# ascii = np . array ( [ ord ( c ) for c in string ] ) . T #NEWLINE# return np . array ( ( ascii [ : , None ] == np . arange ( maxchar ) [ None , : ] ) , dtype = int )