tf.compat.v1.lookup.StaticVocabularyTable

String to Id table that assigns out-of-vocabulary keys to hash buckets.

Inherits From: StaticVocabularyTable

For example, if an instance of StaticVocabularyTable is initialized with a string-to-id initializer that maps:

init = tf.lookup.KeyValueTensorInitializer(
    keys=tf.constant(['emerson', 'lake', 'palmer']),
    values=tf.constant([0, 1, 2], dtype=tf.int64))
table = tf.lookup.StaticVocabularyTable(
   init,
   num_oov_buckets=5)

The Vocabulary object will performs the following mapping:

  • emerson -> 0
  • lake -> 1
  • palmer -> 2
  • <other term> -> bucket_id, where bucket_id will be between 3 and 3 + num_oov_buckets - 1 = 7, calculated by: hash(<term>) % num_oov_buckets + vocab_size

If input_tensor is:

input_tensor = tf.constant(["emerson", "lake", "palmer",