dot

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

Compute the dot product.

\[\text{out} = a \cdot b \]

If rank(a) == rank(b) == 1, compute vector product:

x = dragon.ones((2,))
y = dragon.ones((2,))
print(dragon.math.dot([x, y]))  # 2.0

If rank(a) == rank(b) == 2, compute matrix multiplication:

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

If rank(a) >= 2, rank(b) == 1, compute matrix-vector multiplication:

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

dragon.Tensor – The output tensor.