1D Gaussian Kernel

Hello,

Is there any equivalent for “scipy.ndimage.gaussian_filter1d” in Pytorch? I have a tensor of shape [T, H, W] that I would like to apply a 1d gaussian kernel on its first dimension (T). How can I do so?

Thanks

You could create a gaussian kernel as described e.g. in this post or this one and apply it to your input via F.conv2d.

To add to @ptrblck’s comments, here is what I like to do for images:

To take this to 1d, you save a lot by not needing the funny None-indexing and broadcasting, but you will likely want to rearrange the input tensor to have the folding dimension last to use conv1d.

Best regards

Thomas

1 Like