diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index bb2f2f817a79fdee7ec0b0adbc3e57b440cbd1b7..d9abf18d0ba2a0575cf6952d7e6d913f85992933 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -4486,7 +4486,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None): return helper.append_activation(out) -def squeeze(x, axes, inplace=False, name=None): +def squeeze(input, axes, inplace=False, name=None): """ Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all @@ -4510,7 +4510,7 @@ def squeeze(x, axes, inplace=False, name=None): Out.shape = (3, 5) Args: - x (Variable): The input variable to be squeezed. + input (Variable): The input variable to be squeezed. axes (list): List of integers, indicating the dimensions to be squeezed. name (str|None): Name for this layer. @@ -4521,20 +4521,20 @@ def squeeze(x, axes, inplace=False, name=None): .. code-block:: python x = layers.data(name='x', shape=[5, 1, 10]) - y = layers.sequeeze(x, axes=[1]) + y = layers.sequeeze(input=x, axes=[1]) """ helper = LayerHelper("squeeze", **locals()) - out = helper.create_tmp_variable(dtype=x.dtype) + out = helper.create_tmp_variable(dtype=input.dtype) helper.append_op( type="squeeze", - inputs={"X": x}, + inputs={"X": input}, attrs={"axes": axes}, outputs={"Out": out}) return out -def unsqueeze(x, axes, inplace=False, name=None): +def unsqueeze(input, axes, inplace=False, name=None): """ Insert single-dimensional entries to the shape of a tensor. Takes one required argument axes, a list of dimensions that will be inserted. @@ -4545,7 +4545,7 @@ def unsqueeze(x, axes, inplace=False, name=None): then Unsqueezed tensor with axes=[0, 4] has shape [1, 3, 4, 5, 1]. Args: - x (Variable): The input variable to be unsqueezed. + input (Variable): The input variable to be unsqueezed. axes (list): List of integers, indicating the dimensions to be inserted. name (str|None): Name for this layer. @@ -4556,13 +4556,13 @@ def unsqueeze(x, axes, inplace=False, name=None): .. code-block:: python x = layers.data(name='x', shape=[5, 10]) - y = layers.unsequeeze(x, axes=[1]) + y = layers.unsequeeze(input=x, axes=[1]) """ helper = LayerHelper("unsqueeze", **locals()) - out = helper.create_tmp_variable(dtype=x.dtype) + out = helper.create_tmp_variable(dtype=input.dtype) helper.append_op( type="unsqueeze", - inputs={"X": x}, + inputs={"X": input}, attrs={"axes": axes}, outputs={"Out": out}) diff --git a/python/paddle/fluid/tests/unittests/test_layers.py b/python/paddle/fluid/tests/unittests/test_layers.py index 9f614433d9ad8582a14facc0cf326be8db50d6d0..f2fccd5d76777b183823c684d5e5ace317925bb0 100644 --- a/python/paddle/fluid/tests/unittests/test_layers.py +++ b/python/paddle/fluid/tests/unittests/test_layers.py @@ -244,7 +244,7 @@ class TestBook(unittest.TestCase): program = Program() with program_guard(program): x = layers.data(name='x', shape=[8, 2], dtype='float32') - out = layers.unsqueeze(x=x, axes=[1]) + out = layers.unsqueeze(input=x, axes=[1]) self.assertIsNotNone(out) print(str(program)) @@ -252,7 +252,7 @@ class TestBook(unittest.TestCase): program = Program() with program_guard(program): x = layers.data(name='x', shape=[1, 1, 4], dtype='float32') - out = layers.squeeze(x=x, axes=[2]) + out = layers.squeeze(input=x, axes=[2]) self.assertIsNotNone(out) print(str(program))