tf.contrib.lookup.InitializableLookupTableBase

View source on GitHub

Class InitializableLookupTableBase

Initializable lookup table interface.

Inherits From: LookupInterface

An initializable lookup tables persist across different steps.

__init__

View source

__init__(
    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:

  • default_value: The value to use if a key is missing in the table.
  • initializer: The table initializer to use.

Properties

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

tf.contrib.lookup.InitializableLookupTableBase.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.

tf.contrib.lookup.InitializableLookupTableBase.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.