Created
July 19, 2017 18:01
-
-
Save ibombonato/ac27546a5aaf2a7d00c8c86fb2200aff to your computer and use it in GitHub Desktop.
Using text to sequence in R with 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
library(keras) | |
texts <- c("Today I got to the movie", | |
"Yesterday we got to the movie", | |
"Today was cold at the movie", | |
"Somethign happened yesterday") | |
tok <- keras::text_tokenizer(num_words = 5) | |
keras::fit_text_tokenizer(tok, texts) | |
tok$word_counts | |
tok$word_index | |
texts_sequence <- keras::texts_to_sequences(tok, texts) | |
pad_sequence <- keras::pad_sequences(texts_sequence, maxlen = 5) | |
pad_sequence |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment