Skip to content

Instantly share code, notes, and snippets.

@sai-teja-ponugoti
Created June 1, 2020 04:26
Show Gist options
  • Save sai-teja-ponugoti/fc9beef0c1d55f309c3b82d9528c6308 to your computer and use it in GitHub Desktop.
Save sai-teja-ponugoti/fc9beef0c1d55f309c3b82d9528c6308 to your computer and use it in GitHub Desktop.
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)
@kostasx
Copy link

kostasx commented Jul 12, 2020

First line, needs a 'f'rom tensorflow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment