<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/layers/merging/dot.py#L198-L357) |

Computes element-wise dot product of two tensors.

Inherits From: [`Layer`](https://www.tensorflow.org/api_docs/python/tf/keras/Layer), [`Operation`](https://www.tensorflow.org/api_docs/python/tf/keras/Operation)

    tf.keras.layers.Dot(
        axes, normalize=False, **kwargs
    )

It takes a list of inputs of size 2, and the axes
corresponding to each input along with the dot product
is to be performed.

Let's say `x` and `y` are the two input tensors with shapes
`(2, 3, 5)` and `(2, 10, 3)`. The batch dimension should be
of same size for both the inputs, and `axes` should correspond
to the dimensions that have the same size in the corresponding
inputs. e.g. with `axes=(1, 2)`, the dot product of `x`, and `y`
will result in a tensor with shape `(2, 5, 10)`

#### Example:

    x = np.arange(10).reshape(1, 5, 2)
    y = np.arange(10, 20).reshape(1, 2, 5)
    keras.layers.Dot(axes=(1, 2))([x, y])

Usage in a Keras model:

    x1 = keras.layers.Dense(8)(np.arange(10).reshape(5, 2))
    x2 = keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))
    y = keras.layers.Dot(axes=1)([x1, x2])

<br />

<br />

<br />

| ## Args ||
|---|---|
| `axes` | Integer or tuple of integers, axis or axes along which to take the dot product. If a tuple, should be two integers corresponding to the desired axis from the first input and the desired axis from the second input, respectively. Note that the size of the two selected axes must match, and that axis `0` (the batch axis) cannot be included. |
| `normalize` | Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to `True`, then the output of the dot product is the cosine proximity between the two samples. |
| `**kwargs` | Standard layer keyword arguments. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor, the dot product of the samples from the inputs. ||

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `input` | Retrieves the input tensor(s) of a symbolic operation. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |
| `output` | Retrieves the output tensor(s) of a layer. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |

<br />

## Methods

### `from_config`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/operation.py#L322-L362)

    @classmethod
    from_config(
        config
    )

Creates an operation from its config.

This method is the reverse of `get_config`, capable of instantiating the
same operation from the config dictionary.

> [!NOTE]
> **Note:** If you override this method, you might receive a serialized dtype config, which is a `dict`. You can deserialize it as follows:

    if "dtype" in config and isinstance(config["dtype"], dict):
        policy = dtype_policies.deserialize(config["dtype"])

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary, typically the output of `get_config`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An operation instance. ||

<br />