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

set_vocabulary

Sets vocabulary (and optionally document frequency) data for the layer


Description

This method sets the vocabulary and DF data for this layer directly, instead of analyzing a dataset through adapt(). It should be used whenever the vocab (and optionally document frequency) information is already known. If vocabulary data is already present in the layer, this method will either replace it, if append is set to FALSE, or append to it (if 'append' is set to TRUE)

Usage

set_vocabulary(
  object,
  vocab,
  df_data = NULL,
  oov_df_value = FALSE,
  append = NULL
)

Arguments

object

a text vectorization layer

vocab

An array of string tokens.

df_data

An array of document frequency data. Only necessary if the layer output_mode is "tfidf".

oov_df_value

The document frequency of the OOV token. Only necessary if output_mode is "tfidf". OOV data is optional when appending additional data in "tfidf" mode; if an OOV value is supplied it will overwrite the existing OOV value.

append

Whether to overwrite or append any existing vocabulary data. (deprecated since TensorFlow >= 2.3)

See Also


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.