Skip to content

Commit b586cc2

Browse files
author
Yibing Liu
committed
Fix typos in unsqueeze & unsequeeze wrapper
1 parent 1443d76 commit b586cc2

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,6 +4485,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
44854485

44864486
return helper.append_activation(out)
44874487

4488+
44884489
def squeeze(x, axes, inplace=False, name=None):
44894490
"""
44904491
Remove single-dimensional entries from the shape of a tensor. Takes a
@@ -4511,7 +4512,7 @@ def squeeze(x, axes, inplace=False, name=None):
45114512
Args:
45124513
x (Variable): The input variable to be squeezed.
45134514
axes (list): List of integers, indicating the dimensions to be squeezed.
4514-
name (str): Name for this layers.
4515+
name (str|None): Name for this layer.
45154516
45164517
Returns:
45174518
Variable: Output squeezed variable.
@@ -4530,8 +4531,9 @@ def squeeze(x, axes, inplace=False, name=None):
45304531
attrs={"axes": axes},
45314532
outputs={"Out": out})
45324533

4533-
return out
4534-
4534+
return out
4535+
4536+
45354537
def unsqueeze(x, axes, inplace=False, name=None):
45364538
"""
45374539
Insert single-dimensional entries to the shape of a tensor. Takes one
@@ -4545,7 +4547,7 @@ def unsqueeze(x, axes, inplace=False, name=None):
45454547
Args:
45464548
x (Variable): The input variable to be unsqueezed.
45474549
axes (list): List of integers, indicating the dimensions to be inserted.
4548-
name (str): Name for this layers.
4550+
name (str|None): Name for this layer.
45494551
45504552
Returns:
45514553
Variable: Output unsqueezed variable.
@@ -4564,7 +4566,8 @@ def unsqueeze(x, axes, inplace=False, name=None):
45644566
attrs={"axes": axes},
45654567
outputs={"Out": out})
45664568

4567-
return out
4569+
return out
4570+
45684571

45694572
def lod_reset(x, y=None, target_lod=None):
45704573
"""

python/paddle/fluid/tests/unittests/test_layers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,16 @@ def test_softmax(self):
243243
def test_sequence_unsqueeze(self):
244244
program = Program()
245245
with program_guard(program):
246-
x = layers.data(name='x', shape=[8,2], dtype='float32')
246+
x = layers.data(name='x', shape=[8, 2], dtype='float32')
247247
out = layers.unsqueeze(x=x, axes=[1])
248248
self.assertIsNotNone(out)
249249
print(str(program))
250-
250+
251251
def test_squeeze(self):
252252
program = Program()
253253
with program_guard(program):
254254
x = layers.data(name='x', shape=[1, 1, 4], dtype='float32')
255-
out = layers.squeeze(x=x, axes=[0])
255+
out = layers.squeeze(x=x, axes=[2])
256256
self.assertIsNotNone(out)
257257
print(str(program))
258258

@@ -277,7 +277,6 @@ def test_sequence_reshape(self):
277277
out = layers.sequence_reshape(input=x, new_dim=16)
278278
self.assertIsNotNone(out)
279279
print(str(program))
280-
281280

282281
def test_im2sequence(self):
283282
program = Program()

0 commit comments

Comments
 (0)