MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __init__

Method __init__

tensorflow/python/ops/lookup_ops.py:418–446  ·  view source on GitHub ↗

Constructs a table initializer object based on keys and values tensors. Args: keys: The tensor for the keys. values: The tensor for the values. key_dtype: The `keys` data type. Used when `keys` is a python array. value_dtype: The `values` data type. Used when `values` is

(self, keys, values, key_dtype=None, value_dtype=None, name=None)

Source from the content-addressed store, hash-verified

416 """Table initializers given `keys` and `values` tensors."""
417
418 def __init__(self, keys, values, key_dtype=None, value_dtype=None, name=None):
419 """Constructs a table initializer object based on keys and values tensors.
420
421 Args:
422 keys: The tensor for the keys.
423 values: The tensor for the values.
424 key_dtype: The `keys` data type. Used when `keys` is a python array.
425 value_dtype: The `values` data type. Used when `values` is a python array.
426 name: A name for the operation (optional).
427 """
428 if (not context.executing_eagerly() and
429 ops.get_default_graph()._get_control_flow_context() is not None): # pylint: disable=protected-access
430 with ops.init_scope():
431 self._keys = ops.convert_to_tensor(keys, dtype=key_dtype, name="keys")
432 self._values = ops.convert_to_tensor(
433 values, dtype=value_dtype, name="values")
434 else:
435 self._keys = ops.convert_to_tensor(keys, dtype=key_dtype, name="keys")
436 self._values = ops.convert_to_tensor(
437 values, dtype=value_dtype, name="values")
438 self._name = name if name is not None else "key_value_init"
439 if context.executing_eagerly():
440 # Ensure a unique name when eager execution is enabled to avoid spurious
441 # sharing issues.
442 # TODO(rohanj): Use context.shared_name() instead.
443 self._name += str(ops.uid())
444
445 super(KeyValueTensorInitializer, self).__init__(self._keys.dtype,
446 self._values.dtype)
447
448 def initialize(self, table):
449 """Initializes the given `table` with `keys` and `values` tensors.

Callers

nothing calls this directly

Calls 4

executing_eagerlyMethod · 0.80
uidMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected