# tf.lookup.KeyValueTensorInitializer

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/lookup/KeyValueTensorInitializer) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/lookup_ops.py#L414-L466) |

Table initializers given `keys` and `values` tensors.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.lookup.KeyValueTensorInitializer`](https://www.tensorflow.org/api_docs/python/tf/lookup/KeyValueTensorInitializer)

<br />

    tf.lookup.KeyValueTensorInitializer(
        keys, values, key_dtype=None, value_dtype=None, name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `keys` | The tensor for the keys. |
| `values` | The tensor for the values. |
| `key_dtype` | The `keys` data type. Used when `keys` is a python array. |
| `value_dtype` | The `values` data type. Used when `values` is a python array. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `key_dtype` | The expected table key dtype. |
| `value_dtype` | The expected table value dtype. |

<br />

## Methods

### `initialize`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/lookup_ops.py#L447-L466)

    initialize(
        table
    )

Initializes the given `table` with `keys` and `values` tensors.

<br />

<br />

<br />

| Args ||
|---|---|
| `table` | The table to initialize. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The operation that initializes the table. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `TypeError` | when the keys and values data types do not match the table key and value data types. |

<br />