W3cubDocs

/TensorFlow Python

tf.contrib.lookup.InitializableLookupTableBase

Class InitializableLookupTableBase

Inherits From: LookupInterface

Defined in tensorflow/python/ops/lookup_ops.py.

Initializable lookup table interface.

An initializable lookup tables persist across different steps.

Properties

default_value

The default value of the table.

init

The table initialization op.

key_dtype

The table key dtype.

name

The name of the table.

table_ref

Get the underlying table reference.

value_dtype

The table value dtype.

Methods

__init__

__init__(
    table_ref,
    default_value,
    initializer
)

Construct a table object from a table reference.

If requires a table initializer object (subclass of TableInitializerBase). It provides the table key and value types, as well as the op to initialize the table. The caller is responsible to execute the initialization op.

Args:

  • table_ref: The table reference, i.e. the output of the lookup table ops.
  • default_value: The value to use if a key is missing in the table.
  • initializer: The table initializer to use.

lookup

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

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.

© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/lookup/InitializableLookupTableBase