Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created December 20, 2020 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/0c63423e1f201f9c1acabc0adfd2c734 to your computer and use it in GitHub Desktop.
Save amankharwal/0c63423e1f201f9c1acabc0adfd2c734 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