예제 #1
0
    def initialize(self, table):
        """Initializes the given `table` with `keys` and `values` tensors.

    Args:
      table: The table to initialize.

    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.
    """
        _check_table_dtypes(table, self._keys.dtype, self._values.dtype)
        with ops.name_scope(self._name,
                            values=(table.table_ref, self._keys,
                                    self._values)) as scope:
            # pylint: disable=protected-access
            init_op = gen_lookup_ops._initialize_table_v2(table.table_ref,
                                                          self._keys,
                                                          self._values,
                                                          name=scope)
            # pylint: enable=protected-access
        ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op)
        return init_op
예제 #2
0
  def initialize(self, table):
    """Initializes the given `table` with `keys` and `values` tensors.

    Args:
      table: The table to initialize.

    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.
    """
    _check_table_dtypes(table, self._keys.dtype, self._values.dtype)
    with ops.name_scope(
        self._name, values=(table.table_ref, self._keys,
                            self._values)) as scope:
      # pylint: disable=protected-access
      init_op = gen_lookup_ops._initialize_table_v2(
          table.table_ref, self._keys, self._values, name=scope)
      # pylint: enable=protected-access
    ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op)
    return init_op