# What we should use align\_corners = False

**URL:** <https://discuss.pytorch.org/t/what-we-should-use-align-corners-false/22663>\
**Category:** vision\
**Created:** [August 8, 2018, 12:51pm UTC](https://discuss.pytorch.org/t/what-we-should-use-align-corners-false/22663 "2018-08-08T12:51:54Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ZeluDeng](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/z/58f4c7/32.png) [@ZeluDeng](https://discuss.pytorch.org/u/ZeluDeng)\
**Post date:** [January 3, 2019, 1:50pm UTC](https://discuss.pytorch.org/t/what-we-should-use-align-corners-false/22663/6 "2019-01-03T13:50:23Z")

</div>

Talk is cheap, show you the code!

```python
# align_corners = False
# x_ori is the coordinate in original image
# x_up is the coordinate in the upsampled image
x_ori = (x_up + 0.5) / factor - 0.5

```

```python
# align_corners = True
# h_ori is the height in original image
# h_up is the height in the upsampled image
stride = (h_ori - 1) / (h_up - 1)
x_ori_list = []
# append the first coordinate
x_ori_list.append(0)
for i in range(1, h_up - 1):
    x_ori_list.append(0 + i * stride)
# append the last coordinate
x_ori_list.append(h_ori - 1)

```

---

_[View the full topic](https://discuss.pytorch.org/t/what-we-should-use-align-corners-false/22663)._
