fn
inner
→Tensorinner(x: Tensor, y: Tensor)Inner product over the last axes of two tensors.
Behaves like dot for 1-D inputs and like a generalised
outer-then-contract for higher ranks.
Parameters
xTensorTensors whose last dimensions match.
yTensorTensors whose last dimensions match.
Returns
TensorResult with shape x.shape[:-1] + y.shape[:-1].
Notes
Contracts the last axis of both operands and sums:
For 1-D inputs, this is the standard vector dot product. For higher
ranks the leading axes of x and y are kept independent and
appear consecutively in the output — handy for batched dot products
when the contraction axis is the trailing one.
Examples
>>> import lucid
>>> from lucid.linalg import inner
>>> inner(lucid.tensor([1.0, 2.0]), lucid.tensor([3.0, 4.0]))
Tensor(11.0)