Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

save_text_tokenizer

Save a text tokenizer to an external file


Description

Enables persistence of text tokenizers alongside saved models.

Usage

save_text_tokenizer(object, filename)

load_text_tokenizer(filename)

Arguments

object

Text tokenizer fit with fit_text_tokenizer()

filename

File to save/load

Details

You should always use the same text tokenizer for training and prediction. In many cases however prediction will occur in another session with a version of the model loaded via load_model_hdf5().

In this case you need to save the text tokenizer object after training and then reload it prior to prediction.

See Also

Examples

## Not run: 

# vectorize texts then save for use in prediction
tokenizer <- text_tokenizer(num_words = 10000) %>% 
fit_text_tokenizer(tokenizer, texts)
save_text_tokenizer(tokenizer, "tokenizer")

# (train model, etc.)

# ...later in another session
tokenizer <- load_text_tokenizer("tokenizer")

# (use tokenizer to preprocess data for prediction)


## End(Not run)

keras

R Interface to 'Keras'

v2.4.0
MIT + file LICENSE
Authors
Daniel Falbel [ctb, cph, cre], JJ Allaire [aut, cph], François Chollet [aut, cph], RStudio [ctb, cph, fnd], Google [ctb, cph, fnd], Yuan Tang [ctb, cph] (<https://orcid.org/0000-0001-5243-233X>), Wouter Van Der Bijl [ctb, cph], Martin Studer [ctb, cph], Sigrid Keydana [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.