def onehot_encode(dataset, char_indices, maxlen):
    ' \n    One hot encode the tokens\n    \n    Args:\n        dataset  list of lists of tokens\n        char_indices  dictionary of {key=character, value=index to use encoding vector}\n        maxlen  int  Length of each sample\n    Return:\n        np array of shape (samples, tokens, encoding length)\n    '
    X = np.zeros((len(dataset), maxlen, len(char_indices.keys())))
    for (i, sentence) in enumerate(dataset):
        for (t, char) in enumerate(sentence):
            X[(i, t, char_indices[char])] = 1
    return X
One hot encode the tokens

Args:
    dataset  list of lists of tokens
    char_indices  dictionary of {key=character, value=index to use encoding vector}
    maxlen  int  Length of each sample
Return:
    np array of shape (samples, tokens, encoding length)
def onehot_encode(dataset, char_indices, maxlen):
    ' \n    One hot encode the tokens\n    \n    Args:\n        dataset  list of lists of tokens\n        char_indices  dictionary of {key=character, value=index to use encoding vector}\n        maxlen  int  Length of each sample\n    Return:\n        np array of shape (samples, tokens, encoding length)\n    '
    X = np.zeros((len(dataset), maxlen, len(char_indices.keys())))
    for (i, sentence) in enumerate(dataset):
        for (t, char) in enumerate(sentence):
            X[(i, t, char_indices[char])] = 1
    return X