Created
May 22, 2020 00:48
-
-
Save VincentTatan/75826251c3be4e6f633398f8c70ca0a8 to your computer and use it in GitHub Desktop.
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
from tensorflow.keras.preprocessing.sequence import pad_sequences | |
sequences = tokenizer.texts_to_sequences(sentences) | |
padded = pad_sequences(sequences, maxlen=5) | |
print("\nThe Word Index = " , word_index) | |
print("\nThe Sequences = " , sequences) | |
print("\nThe Padded Sequences:") | |
print(padded) | |
# Test data with sentences we have never seen | |
test_data = [ | |
'i really love fish', | |
'you love to eat fish so much' | |
] | |
test_seq = tokenizer.texts_to_sequences(test_data) | |
print("\nTest Sequence = ", test_seq) | |
padded = pad_sequences(test_seq) | |
print("\nPadded Test Sequence: ") | |
print(padded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment