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

Method initialize

tensorflow/python/ops/lookup_ops.py:634–660  ·  view source on GitHub ↗

Initializes the table from a text file. Args: table: The table to be initialized. Returns: The operation that initializes the table. Raises: TypeError: when the keys and values data types do not match the table key and value data types.

(self, table)

Source from the content-addressed store, hash-verified

632 super(TextFileInitializer, self).__init__(key_dtype, value_dtype)
633
634 def initialize(self, table):
635 """Initializes the table from a text file.
636
637 Args:
638 table: The table to be initialized.
639
640 Returns:
641 The operation that initializes the table.
642
643 Raises:
644 TypeError: when the keys and values data types do not match the table
645 key and value data types.
646 """
647 _check_table_dtypes(table, self.key_dtype, self.value_dtype)
648 with ops.name_scope(self._name, "text_file_init", (table.resource_handle,)):
649 filename = ops.convert_to_tensor(
650 self._filename, dtypes.string, name="asset_filepath")
651 init_op = gen_lookup_ops.initialize_table_from_text_file_v2(
652 table.resource_handle, filename, self._key_index, self._value_index,
653 -1 if self._vocab_size is None else self._vocab_size, self._delimiter)
654 ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op)
655 # If the filename tensor is anything other than a string constant (e.g.,
656 # if it is a placeholder) then it does not make sense to track it as an
657 # asset.
658 if not context.executing_eagerly() and constant_op.is_constant(filename):
659 ops.add_to_collection(ops.GraphKeys.ASSET_FILEPATHS, filename)
660 return init_op
661
662 @property
663 def _shared_name(self):

Callers

nothing calls this directly

Calls 5

_check_table_dtypesFunction · 0.85
add_to_collectionMethod · 0.80
executing_eagerlyMethod · 0.80
name_scopeMethod · 0.45
is_constantMethod · 0.45

Tested by

no test coverage detected