# Any way to apply gaussian smoothing on tensor?

**URL:** <https://discuss.pytorch.org/t/any-way-to-apply-gaussian-smoothing-on-tensor/13842>\
**Category:** Uncategorized\
**Created:** [February 20, 2018, 11:26am UTC](https://discuss.pytorch.org/t/any-way-to-apply-gaussian-smoothing-on-tensor/13842 "2018-02-20T11:26:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![soshishimada](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/soshishimada/32/2278_2.png) [@soshishimada](https://discuss.pytorch.org/u/soshishimada)\
**Post date:** [February 20, 2018, 11:26am UTC](https://discuss.pytorch.org/t/any-way-to-apply-gaussian-smoothing-on-tensor/13842/1 "2018-02-20T11:26:26Z")

</div>

I want to apply gaussian filter on output of the network for smoothing purpose.  
Is there a function for that?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [February 20, 2018, 2:29pm UTC](https://discuss.pytorch.org/t/any-way-to-apply-gaussian-smoothing-on-tensor/13842/2 "2018-02-20T14:29:12Z")

</div>

You could use the functional API with your custom weights:

```auto
# Create gaussian kernels
kernel = Variable(torch.FloatTensor([[[0.006, 0.061, 0.242, 0.383, 0.242, 0.061, 0.006]]]))
# Create input
x = Variable(torch.randn(1, 1, 100))
# Apply smoothing
x_smooth = F.conv1d(x, kernel)

```
