# How to resize feature maps?

**URL:** <https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545>\
**Category:** Uncategorized\
**Created:** [May 23, 2018, 5:09am UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545 "2018-05-23T05:09:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miladiouss](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/miladiouss/32/5244_2.png) [@miladiouss](https://discuss.pytorch.org/u/miladiouss)\
**Post date:** [May 23, 2018, 5:09am UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545/1 "2018-05-23T05:09:58Z")

</div>

I want to rescale (i.e. resize) the output of a convolution layer. I don’t mean to reshape the tensor, but actually make an _n_ by _n_ map and change it to an _m_ by _m_ for the entire minibatch. Is this possible in PyTorch?

---

<div class="post-metadata">

**Author:** ![sniklaus](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sniklaus/32/3390_2.png) [@sniklaus](https://discuss.pytorch.org/u/sniklaus)\
**Post date:** [May 23, 2018, 6:28am UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545/2 "2018-05-23T06:28:36Z")

</div>

You could have a look at the Upsample module.

[https://pytorch.org/docs/master/nn.html#torch.nn.Upsample](https://pytorch.org/docs/master/nn.html#torch.nn.Upsample)

---

<div class="post-metadata">

**Author:** ![miladiouss](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/miladiouss/32/5244_2.png) [@miladiouss](https://discuss.pytorch.org/u/miladiouss)\
**Post date:** [May 23, 2018, 11:07pm UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545/3 "2018-05-23T23:07:19Z")

</div>

That is helpful, but my goal is to downsample to an arbitrary size. Let’s say I have 12 x 64 x 64 feature map and want to change it to a 12 x 50 x 50. Using downsampling/padding doesn’t always work.

---

<div class="post-metadata">

**Author:** ![sniklaus](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sniklaus/32/3390_2.png) [@sniklaus](https://discuss.pytorch.org/u/sniklaus)\
**Post date:** [May 23, 2018, 11:28pm UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545/4 "2018-05-23T23:28:39Z")

</div>

What operation do you want to use, how do you want to map values from one domain into the other?

I am also not sure why the following isn’t what you were looking for.

`torch.nn.Upsample(size=(50, 50), mode='bilinear')(torch.rand(1, 3, 64, 64))`

---

<div class="post-metadata">

**Author:** ![miladiouss](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/miladiouss/32/5244_2.png) [@miladiouss](https://discuss.pytorch.org/u/miladiouss)\
**Post date:** [June 8, 2018, 5:42am UTC](https://discuss.pytorch.org/t/how-to-resize-feature-maps/18545/5 "2018-06-08T05:42:38Z")

</div>

Oh, I can use **Upsample** to _downsample_! I guess the name confused me. Thank you Simon; this is exactly what I am looking for! I am loving PyTroch.
