diff --git a/paddle/fluid/operators/interpolate_op.cc b/paddle/fluid/operators/interpolate_op.cc index 13be33a391f96fb2c1ff02109e431366c45290b2..83b2086bbb8f24835b0cefb9ef11e6d21e7b4114 100644 --- a/paddle/fluid/operators/interpolate_op.cc +++ b/paddle/fluid/operators/interpolate_op.cc @@ -128,7 +128,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker { Nearest neighbor interpolation: - case 1: + if: align_corners = False input : (N,C,H_in,W_in) @@ -137,7 +137,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker { H_out = \left \lfloor {H_{in} * scale_{}factor}} \right \rfloor W_out = \left \lfloor {W_{in} * scale_{}factor}} \right \rfloor - case 2: + else: align_corners = True input : (N,C,H_in,W_in) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 765fa8565be0543d3625df34d4a36d7fe1068b49..4d40f2e7c2a39567e1811f1f2e4e794865c4896a 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -6570,7 +6570,7 @@ def image_resize(input, Nearest neighbor interpolation: - case 1: + if: align_corners = False input : (N,C,H_in,W_in) @@ -6579,7 +6579,7 @@ def image_resize(input, H_out = \left \lfloor {H_{in} * scale_{}factor}} \right \rfloor W_out = \left \lfloor {W_{in} * scale_{}factor}} \right \rfloor - case 2: + else: align_corners = True input : (N,C,H_in,W_in) @@ -6866,7 +6866,7 @@ def resize_nearest(input, Nearest neighbor interpolation: - case 1: + if: align_corners = False input : (N,C,H_in,W_in) @@ -6875,7 +6875,7 @@ def resize_nearest(input, H_out = \left \lfloor {H_{in} * scale_{}factor}} \right \rfloor W_out = \left \lfloor {W_{in} * scale_{}factor}} \right \rfloor - case 2: + else: align_corners = True input : (N,C,H_in,W_in) diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index c97aa886a9aaa83bab10ab192ca835a6a8ce6b75..9984a793cae5774f122db05c30c7f1e24e1d78bc 100644 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -208,7 +208,7 @@ class TestNearestNeighborInterpCase1Uint8(TestNearestInterpOpUint8): self.input_shape = [2, 3, 128, 64] self.out_h = 120 self.out_w = 50 - self.align_corners = False + self.align_corners = True class TestNearestNeighborInterpCase2Uint8(TestNearestInterpOpUint8):