![]() |
Computes element-wise dot product of two tensors.
Inherits From: Layer
, Operation
tf.keras.layers.Dot( axes, normalize=False, **kwargs )
Used in the notebooks
Used in the tutorials |
---|
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])
Returns | |
---|---|
A tensor, the dot product of the samples from the inputs. |
Methods
from_config
@classmethod
from_config( config )
Creates a layer from its config.
This method is the reverse of get_config
, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights
).
Args | |
---|---|
config | A Python dictionary, typically the output of get_config. |
Returns | |
---|---|
A layer instance. |
symbolic_call
symbolic_call( *args, **kwargs )