# Max pooling immediately followed by upsampling

**URL:** <https://discuss.pytorch.org/t/max-pooling-immediately-followed-by-upsampling/23286>\
**Category:** vision\
**Created:** [August 16, 2018, 5:40pm UTC](https://discuss.pytorch.org/t/max-pooling-immediately-followed-by-upsampling/23286 "2018-08-16T17:40:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yakirs](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/90ced4/32.png) [@Yakirs](https://discuss.pytorch.org/u/Yakirs)\
**Post date:** [August 16, 2018, 5:40pm UTC](https://discuss.pytorch.org/t/max-pooling-immediately-followed-by-upsampling/23286/1 "2018-08-16T17:40:30Z")

</div>

I saw in some code that I’m using something like that:

```
...
out = torch.nn.functional.max_pool2d(out, kernel_size=2, stride=2)
out = nn.functional.upsample(out, scale_factor=2)
....

```

It seems odd and I don’t really see the value in that. Any ideas?

P.S:  
I know the code was adapted from some torch (LUA) code, but it seems to have the exact same meaning:

```
....
local out = nn.SpatialMaxPooling(2,2,2,2)(out)
local out = nn.SpatialUpSamplingNearest(2)(out)
...
```
