diff --git a/doc/fluid/api/layers.rst b/doc/fluid/api/layers.rst index dbb99d3c03f39f650b2cb0dbe8ee49cd413db6e3..5329adaa18ba3309a1aeda7e24c9d0d3b26ea377 100644 --- a/doc/fluid/api/layers.rst +++ b/doc/fluid/api/layers.rst @@ -1003,10 +1003,10 @@ dice_loss .. autofunction:: paddle.fluid.layers.dice_loss :noindex: -upsampling_bilinear2d +resize_bilinear ____ -.. autofunction:: paddle.fluid.layers.upsampling_bilinear2d +.. autofunction:: paddle.fluid.layers.resize_bilinear :noindex: gather diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 56f5c6b4bedb6ae864c5b6f54afc758b8be8c415..bd6ed0f30e4d71df7a4e84c6dd3472c391008393 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -81,7 +81,7 @@ __all__ = [ 'label_smooth', 'roi_pool', 'dice_loss', - 'upsampling_bilinear2d', + 'resize_bilinear', 'gather', 'random_crop', ] @@ -3929,9 +3929,9 @@ def dice_loss(input, label, epsilon=0.00001): return reduce_mean(dice_score) -def upsampling_bilinear2d(input, out_shape=None, scale=None, name=None): +def resize_bilinear(input, out_shape=None, scale=None, name=None): """ - The mathematical meaning of upsampling_bilinear2d is also called + The mathematical meaning of resize bilinear layer is Bilinear interpolation. Bilinear interpolation is an extension of linear interpolation for interpolating functions of two variables (e.g. H-direction and @@ -3941,13 +3941,13 @@ def upsampling_bilinear2d(input, out_shape=None, scale=None, name=None): https://en.wikipedia.org/wiki/Bilinear_interpolation Args: - input (Variable): The input tensor of bilinear interpolation, + input (Variable): The input tensor of resize bilinear layer, This is a 4-D tensor of the shape (num_batches, channels, in_h, in_w). - out_shape(list|tuple|Variable|None): Output shape of bilinear interpolation + out_shape(list|tuple|Variable|None): Output shape of resize bilinear layer, the shape is (out_h, out_w). Default: None - scale(int|None): The multiplier for the input height or width. + scale(float|None): The multiplier for the input height or width. At least one of out_shape or scale must be set. And out_shape has a higher priority than scale. Default: None @@ -3961,7 +3961,7 @@ def upsampling_bilinear2d(input, out_shape=None, scale=None, name=None): Examples: .. code-block:: python - out = fluid.layers.bilinear_interp(input, out_shape=[12, 12]) + out = fluid.layers.resize_bilinear(input, out_shape=[12, 12]) """ if out_shape is None and scale is None: raise ValueError("One of out_shape and scale must not be None") @@ -3975,10 +3975,9 @@ def upsampling_bilinear2d(input, out_shape=None, scale=None, name=None): out_w = 0 inputs = {"X": input} if out_shape is not None: - if not (_is_list_or_turple_(out_shape) and len(out_shape) == 2) and ( - out_shape is not Variable): - raise ValueError('out_shape should be a list or tuple ', - 'with length 2, (out_h, out_w).') + if not (_is_list_or_turple_(out_shape) and + len(out_shape) == 2) and not isinstance(out_shape, Variable): + raise ValueError('out_shape should be a list or tuple or variable') if _is_list_or_turple_(out_shape): out_shape = list(map(int, out_shape)) out_h = out_shape[0] diff --git a/python/paddle/fluid/tests/unittests/test_layers.py b/python/paddle/fluid/tests/unittests/test_layers.py index 60dc1f83fc32e2551eb2a04ef35f1c8a0ffec769..ca08fd7fc8e452b36a984ee5db3832e65e97ef78 100644 --- a/python/paddle/fluid/tests/unittests/test_layers.py +++ b/python/paddle/fluid/tests/unittests/test_layers.py @@ -369,13 +369,13 @@ class TestBook(unittest.TestCase): self.assertIsNotNone(output) print(str(program)) - def test_upsampling_bilinear2d(self): + def test_resize_bilinear(self): program = Program() with program_guard(program): x = layers.data(name='x', shape=[3, 9, 6], dtype="float32") - output = layers.upsampling_bilinear2d(x, out_shape=[12, 12]) + output = layers.resize_bilinear(x, out_shape=[12, 12]) self.assertIsNotNone(output) - output = layers.upsampling_bilinear2d(x, scale=3) + output = layers.resize_bilinear(x, scale=3) self.assertIsNotNone(output) print(str(program))