def __init__(self, initializer, default_value, shared_name=None, name=None): """Creates a non-initialized `HashTable` object. Creates a table, the type of its keys and values are specified by the initializer. Before using the table you will have to initialize it. After initialization the table will be immutable. Args: initializer: The table initializer to use. See `HashTable` kernel for supported key and value types. default_value: The value to use if a key is missing in the table. shared_name: If non-empty, this table will be shared under the given name across multiple sessions. name: A name for the operation (optional). Returns: A `HashTable` object. """ with ops.name_scope(name, "hash_table", (initializer, default_value)) as scope: table_ref = gen_lookup_ops.hash_table_v2( shared_name=shared_name, key_dtype=initializer.key_dtype, value_dtype=initializer.value_dtype, name=scope) super(HashTable, self).__init__(table_ref, default_value, initializer) self._value_shape = self._default_value.get_shape()
def __init__(self, initializer, default_value, shared_name=None, name=None): """Creates a non-initialized `HashTable` object. Creates a table, the type of its keys and values are specified by the initializer. Before using the table you will have to initialize it. After initialization the table will be immutable. Args: initializer: The table initializer to use. See `HashTable` kernel for supported key and value types. default_value: The value to use if a key is missing in the table. shared_name: If non-empty, this table will be shared under the given name across multiple sessions. name: A name for the operation (optional). Returns: A `HashTable` object. """ with ops.name_scope(name, "hash_table", (initializer, default_value)) as scope: table_ref = gen_lookup_ops.hash_table_v2( shared_name=shared_name, key_dtype=initializer.key_dtype, value_dtype=initializer.value_dtype, name=scope) super(HashTable, self).__init__(table_ref, default_value, initializer) self._value_shape = self._default_value.get_shape()
def create_resource(self): with ops.name_scope(self._name, "hash_table", (self._initializer, self._default_value)) as scope: table_ref = gen_lookup_ops.hash_table_v2( shared_name=self._shared_name, key_dtype=self._initializer.key_dtype, value_dtype=self._initializer.value_dtype, name=scope) self._table_name = scope.split("/")[-2] return table_ref
def create_resource(self): with ops.name_scope(self._name, "hash_table", (self._initializer, self._default_value)) as scope: table_ref = gen_lookup_ops.hash_table_v2( shared_name=self._shared_name, key_dtype=self._initializer.key_dtype, value_dtype=self._initializer.value_dtype, name=scope) self._table_name = scope.split("/")[-2] return table_ref
def create_resource(self): table_ref = gen_lookup_ops.hash_table_v2( shared_name=self._shared_name, key_dtype=self._initializer.key_dtype, value_dtype=self._initializer.value_dtype, name=self._name) if context.executing_eagerly(): self._table_name = None else: self._table_name = table_ref.op.name.split("/")[-1] return table_ref
def create_resource(self): table_ref = gen_lookup_ops.hash_table_v2( shared_name=self._shared_name, key_dtype=self._initializer.key_dtype, value_dtype=self._initializer.value_dtype, name=self._name) if context.executing_eagerly(): self._table_name = None else: self._table_name = table_ref.op.name.split("/")[-1] return table_ref
def _create_resource(self): table_ref = gen_lookup_ops.hash_table_v2( shared_name=self._shared_name, key_dtype=self._initializer.key_dtype, value_dtype=self._initializer.value_dtype, name=self._name) if context.executing_eagerly(): self._table_name = None else: op_name = self._table_ref.op.name.split("/")[-1] super(MutableDenseHashTable, self).__init__( key_dtype, value_dtype, op_name)