Skip to content

Instantly share code, notes, and snippets.

Created October 5, 2020 03:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
def generate_padded_sequences(input_sequences):
max_sequence_len = max([len(x) for x in input_sequences])
input_sequences = np.array(pad_sequences(input_sequences, maxlen=max_sequence_len, padding=’pre’))
predictors, label = input_sequences[:,:-1], input_sequences[:, -1]
label = ku.to_categorical(label, num_classes = total_words)
return predictors, label, max_sequence_len
predictors, label, max_sequence_len = generate_padded_sequences(inp_sequences)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment