def initialize(self, table): """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. """ # pylint: disable=protected-access table._check_table_dtypes(self.key_dtype, self.value_dtype) with ops.name_scope(self._name, "text_file_init", [table]) as scope: filename = ops.convert_to_tensor(self._filename, dtypes.string, name="asset_filepath") init_op = gen_data_flow_ops._initialize_table_from_text_file( table.table_ref, filename, self._key_index, self._value_index, -1 if self._vocab_size is None else self._vocab_size, self._delimiter, name=scope) # pylint: enable=protected-access ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op) ops.add_to_collection(ops.GraphKeys.ASSET_FILEPATHS, filename) return init_op
def initialize(self, table): """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. """ # pylint: disable=protected-access table._check_table_dtypes(self.key_dtype, self.value_dtype) with ops.name_scope(self._name, "text_file_init", [table]) as scope: filename = ops.convert_to_tensor(self._filename, dtypes.string, name="asset_filepath") init_op = gen_data_flow_ops._initialize_table_from_text_file( table.table_ref, filename, self._key_index, self._value_index, -1 if self._vocab_size is None else self._vocab_size, self._delimiter, name=scope) # pylint: enable=protected-access ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op) ops.add_to_collection(ops.GraphKeys.ASSET_FILEPATHS, filename) return init_op