dot¶
- paddle. dot ( x, y, name=None ) [source]
-
This operator calculates inner product for vectors.
Note
Support 1-d and 2-d Tensor. When it is 2d, the first dimension of this matrix is the batch dimension, which means that the vectors of multiple batches are dotted.
- Parameters
-
x (Tensor) – 1-D or 2-D
Tensor
. Its dtype should befloat32
,float64
,int32
,int64
,complex64
,complex128
y (Tensor) – 1-D or 2-D
Tensor
. Its dtype should befloat32
,float64
,int32
,int64
,complex64
,complex128
name (str, optional) – Name of the output. Default is None. It’s used to print debug info for developers. Details: Name
- Returns
-
the calculated result Tensor.
- Return type
-
Tensor
Examples
>>> import paddle >>> # 1-D Tensor * 1-D Tensor >>> x = paddle.to_tensor([1, 2, 3]) >>> y = paddle.to_tensor([4, 5, 6]) >>> z = paddle.dot(x, y) >>> print(z) Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True, 32) >>> # 2-D Tensor * 2-D Tensor >>> x = paddle.to_tensor([[1, 2, 3], [2, 4, 6]]) >>> y = paddle.to_tensor([[4, 5, 6], [4, 5, 6]]) >>> z = paddle.dot(x, y) >>> print(z) Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True, [32, 64])