Replaced convolve1d by ad-hoc gradient computation