Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 5, 2020 03:50
Show Gist options
  • Save amankharwal/189d519843313633bd6bd1af1edb44c2 to your computer and use it in GitHub Desktop.
Save amankharwal/189d519843313633bd6bd1af1edb44c2 to your computer and use it in GitHub Desktop.
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