dot

dragon.math.dot(
  inputs,
  **kwargs
)[source]

Compute the dot product.

\[\text{out} = \text{input1} \cdot \text{input2} \]

If rank(input1) == rank(input2) == 1, compute vector product:

a = dragon.ones((2,))
b = dragon.ones((2,))
print(dragon.math.dot([a, b]))  # 2.0

If rank(input1) == rank(input2) == 2, compute matrix multiplication:

a = dragon.ones((2, 3))
b = dragon.ones((3, 2))
print(dragon.math.dot([a, b]))  # [[[3. 3.], [3. 3.]]]
print(dragon.math.matmul([a, b]))  # Equivalent

If rank(input1) >= 2, rank(input2) == 1, compute matrix-vector multiplication:

a = dragon.ones((2, 3))
b = dragon.ones((3,))
print(dragon.math.dot([a, b]))  # [[3. 3.]]
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The input1 and input2 tensor.
Returns:

dragon.Tensor – The output tensor.