Looks up `keys` in a table, outputs the corresponding values. The `default_value` is used for keys not present in the table. Args: keys: Keys to look up. Can be a tensor of any shape. Must match the table's key_dtype. name: A name for the operation (optional). Retu
(self, keys, name=None)
| 1959 | return gen_lookup_ops.lookup_table_size_v2(self.resource_handle) |
| 1960 | |
| 1961 | def lookup(self, keys, name=None): |
| 1962 | """Looks up `keys` in a table, outputs the corresponding values. |
| 1963 | |
| 1964 | The `default_value` is used for keys not present in the table. |
| 1965 | |
| 1966 | Args: |
| 1967 | keys: Keys to look up. Can be a tensor of any shape. Must match the |
| 1968 | table's key_dtype. |
| 1969 | name: A name for the operation (optional). |
| 1970 | |
| 1971 | Returns: |
| 1972 | A tensor containing the values in the same shape as `keys` using the |
| 1973 | table's value type. |
| 1974 | |
| 1975 | Raises: |
| 1976 | TypeError: when `keys` do not match the table data types. |
| 1977 | """ |
| 1978 | with ops.name_scope(name, "%s_lookup_table_find" % self.name, |
| 1979 | [self.resource_handle, keys]): |
| 1980 | keys = ops.convert_to_tensor(keys, dtype=self._key_dtype, name="keys") |
| 1981 | with ops.colocate_with(self.resource_handle): |
| 1982 | values = gen_lookup_ops.lookup_table_find_v2(self.resource_handle, keys, |
| 1983 | self._default_value) |
| 1984 | |
| 1985 | return values |
| 1986 | |
| 1987 | def insert_or_assign(self, keys, values, name=None): |
| 1988 | """Associates `keys` with `values`. |