# What is the effect of Torch.nn.Upsample VS F.resize

**URL:** <https://discuss.pytorch.org/t/what-is-the-effect-of-torch-nn-upsample-vs-f-resize/108699>\
**Category:** Uncategorized\
**Created:** [January 13, 2021, 9:59am UTC](https://discuss.pytorch.org/t/what-is-the-effect-of-torch-nn-upsample-vs-f-resize/108699 "2021-01-13T09:59:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ripley](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@Ripley](https://discuss.pytorch.org/u/Ripley)\
**Post date:** [January 13, 2021, 9:59am UTC](https://discuss.pytorch.org/t/what-is-the-effect-of-torch-nn-upsample-vs-f-resize/108699/1 "2021-01-13T09:59:00Z")

</div>

Hi,

Just curious to know if there is a difference in terms of the pixel value or any if I use torch.nn.upsample vs F.resize? assuming both functions resize/upsample to the same pixel size and the resampling method is Nearest.

Thank you!

---

<div class="post-metadata">

**Author:** ![ccoding](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ccoding/32/34963_2.png) [@ccoding](https://discuss.pytorch.org/u/ccoding)\
**Post date:** [January 13, 2021, 10:10am UTC](https://discuss.pytorch.org/t/what-is-the-effect-of-torch-nn-upsample-vs-f-resize/108699/2 "2021-01-13T10:10:47Z")

</div>

They are the same inside.  
When you look inside the source code of [torch.nn.upsample](https://pytorch.org/docs/stable/_modules/torch/nn/modules/upsampling.html#Upsample), you will find that the `forward` function of `upsample` is relized by F.resize( I think you maybe point [interpolate](https://pytorch.org/docs/stable/nn.functional.html?highlight=interpolate#torch.nn.functional.interpolate) function)

```python
def forward(self, input: Tensor) -> Tensor:
    return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)

```
