tf.lookup.StaticHashTable
Stay organized with collections
Save and categorize content based on your preferences.
A generic hash table that is immutable once initialized.
tf.lookup.StaticHashTable(
initializer, default_value, name=None
)
Example usage:
keys_tensor = tf.constant([1, 2])
vals_tensor = tf.constant([3, 4])
input_tensor = tf.constant([1, 5])
table = tf.lookup.StaticHashTable(
tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor), -1)
print(table.lookup(input_tensor))
Args |
initializer
|
The table initializer to use. See HashTable kernel for
supported key and value types.
|
default_value
|
The value to use if a key is missing in the table.
|
name
|
A name for the operation (optional).
|
Attributes |
default_value
|
The default value of the table.
|
key_dtype
|
The table key dtype.
|
name
|
The name of the table.
|
resource_handle
|
Returns the resource handle associated with this Resource.
|
value_dtype
|
The table value dtype.
|
Methods
export
View source
export(
name=None
)
Returns tensors of all keys and values in the table.
Args |
name
|
A name for the operation (optional).
|
Returns |
A pair of tensors with the first tensor containing all keys and the
second tensors containing all values in the table.
|
lookup
View source
lookup(
keys, name=None
)
Looks up keys
in a table, outputs the corresponding values.
The default_value
is used for keys not present in the table.
Args |
keys
|
Keys to look up. May be either a SparseTensor or dense Tensor .
|
name
|
A name for the operation (optional).
|
Returns |
A SparseTensor if keys are sparse, otherwise a dense Tensor .
|
Raises |
TypeError
|
when keys or default_value doesn't match the table data
types.
|
size
View source
size(
name=None
)
Compute the number of elements in this table.
Args |
name
|
A name for the operation (optional).
|
Returns |
A scalar tensor containing the number of elements in this table.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[]]