Created
June 1, 2020 04:26
-
-
Save sai-teja-ponugoti/fc9beef0c1d55f309c3b82d9528c6308 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
rom tensorflow.keras.preprocessing.sequence import pad_sequences | |
sentences = ['I love my dog', | |
'I love my cat', | |
'you love my dog!', | |
'Do you think my dog is amazing?', | |
] | |
tokenizer = Tokenizer(num_words = 100,oov_token="<OOV>") | |
tokenizer.fit_on_texts(sentences) | |
word_index = tokenizer.word_index | |
sequences = tokenizer.texts_to_sequences(sentences) | |
# padding sequences | |
padded = pad_sequences(sequences) | |
print(word_index) | |
print(sequences) | |
print(padded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First line, needs a 'f'rom tensorflow...