mindspore.numpy.convolve¶

mindspore.numpy.convolve(a, v, mode="full")[source]

Returns the discrete, linear convolution of two one-dimensional sequences.

Note

If v is longer than a, the tensors are swapped before computation.

Parameters
• a (Union[list, tuple, Tensor]) – First one-dimensional input tensor.

• v (Union[list, tuple, Tensor]) – Second one-dimensional input tensor.

• mode (str, optional) – By default, mode is ‘full’. This returns the convolution at each point of overlap, with an output shape of $$(N+M-1,)$$. At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen. If mode is ‘same’, it returns output of length $$max(M, N)$$. Boundary effects are still visible. If mode is ‘valid’, it returns output of length $$max(M, N) - min(M, N) + 1$$. The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect.

Returns

Tensor, discrete, linear convolution of a and v.

Raises
• TypeError – if the inputs have types not specified above.

• ValueError – if a and v are empty or have wrong dimensions

Supported Platforms:

GPU

Examples

>>> import mindspore.numpy as np
>>> output = np.convolve([1., 2., 3., 4., 5.], [2., 3.], mode="valid")
>>> print(output)
[ 7. 12. 17. 22.]