def string_to_one_hot(string, maxchar):
    ascii = np.array([ord(c) for c in string]).T
    return np.array(ascii[:,None] == np.arange(maxchar)[None, :], dtype=int)
Converts an ASCII string to a one-of-k encoding.
dataset/ETHPy150Open HIPS/autograd/examples/rnn.py/string_to_one_hot