mv

paddle. mv ( x, vec, name=None ) [source]

Performs a matrix-vector product of the matrix x and the vector vec.

Parameters
  • x (Tensor) – A tensor with shape \([M, N]\) , The data type of the input Tensor x should be one of float32, float64.

  • vec (Tensor) – A tensor with shape \([N]\) , The data type of the input Tensor x should be one of float32, float64.

  • name (str, optional) – Normally there is no need for user to set this property. For more information, please refer to Name. Default is None.

Returns

The tensor which is producted by x and vec.

Return type

Tensor

Examples

>>> # x: [M, N], vec: [N]
>>> # paddle.mv(x, vec)  # out: [M]

>>> import paddle

>>> x = paddle.to_tensor([[2, 1, 3], [3, 0, 1]]).astype("float64")
>>> vec = paddle.to_tensor([3, 5, 1]).astype("float64")
>>> out = paddle.mv(x, vec)
>>> print(out)
Tensor(shape=[2], dtype=float64, place=Place(cpu), stop_gradient=True,
[14., 10.])