Created
January 26, 2019 18:05
-
-
Save ashokc/70bc2921f5456736e7dcbea5480d3236 to your computer and use it in GitHub Desktop.
Padded sequences from Keras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn text into 200-long integer sequences, padding with 0 if necessary to maintain the length at 200 | |
import keras | |
sequenceLength = 200 | |
kTokenizer = keras.preprocessing.text.Tokenizer() | |
kTokenizer.fit_on_texts(X) | |
encoded_docs = kTokenizer.texts_to_sequences(X) | |
Xencoded = keras.preprocessing.sequence.pad_sequences(encoded_docs, maxlen=sequenceLength, padding='post') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment