I'm trying to do this:
h = [0.2,0.2,0.2,0.2,0.2]
Y = np.convolve(Y, h, "same")
Y
looks like this:
While doing this I get this error:
ValueError: object too deep for desired array
Why is this?
My guess is because somehow the convolve
function does not see Y
as a 1D array.
This question is related to
python
numpy
convolution
valueerror
You could try using scipy.ndimage.convolve
it allows convolution of multidimensional images. here is the docs
np.convolve
needs a flattened array as one of it's inputs, you can use numpy.ndarray.flatten()
which is quite fast, find it here.
np.convolve()
takes one dimension array. You need to check the input and convert it into 1D.
You can use the np.ravel()
, to convert the array to one dimension.
Source: Stackoverflow.com