Skip to content

Commit 18e71bd

Browse files
authored
Revert "Fix some Bugs of Undefined Variable (#33488)" (#33538)
This reverts commit b2afc8d.
1 parent 308467c commit 18e71bd

File tree

10 files changed

+8
-13
lines changed

10 files changed

+8
-13
lines changed

python/paddle/distributed/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from contextlib import closing
2626
import socket
2727
from paddle.fluid import core
28-
from distutils.util import strtobool
2928

3029
__all__ = [ #noqa
3130
'get_host_name_ip',
@@ -385,7 +384,7 @@ def add_arguments(argname, type, default, help, argparser, **kwargs):
385384
add_argument("name", str, "Jonh", "User name.", parser)
386385
args = parser.parse_args()
387386
"""
388-
type = strtobool if type == bool else type
387+
type = distutils.util.strtobool if type == bool else type
389388
argparser.add_argument(
390389
"--" + argname,
391390
default=default,

python/paddle/fluid/dataloader/collate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def default_collate_fn(batch):
7878

7979
raise TypeError("batch data con only contains: tensor, numpy.ndarray, "
8080
"dict, list, number, but got {}".format(type(sample)))
81+
return outputs
8182

8283

8384
def default_convert_fn(batch):

python/paddle/fluid/optimizer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
from __future__ import print_function
1616

17-
import warnings
1817
import numpy as np
1918
import six
2019
import os
2120
import logging
2221
from collections import defaultdict
2322

2423
import paddle
25-
import paddle.fluid as fluid
2624
from paddle.fluid.distribute_lookup_table import find_distributed_lookup_table
2725
from paddle.fluid.framework import Program, Variable, name_scope, default_main_program, default_startup_program, device_guard
2826

@@ -1471,7 +1469,7 @@ def __init__(self,
14711469
assert isinstance(
14721470
num_trainers, int
14731471
), "The type of num_trainers should be 'int', but received %s" % type(
1474-
num_trainers)
1472+
value)
14751473
assert num_trainers > 0, "The value of num_trainers should be greater than 0!"
14761474

14771475
self._num_trainers = num_trainers

python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import numpy as np
1919
import paddle.fluid.core as core
2020
from paddle.fluid.tests.unittests.op_test import OpTest
21-
from paddle import enable_static
2221

2322
from paddle.fluid.tests.unittests.test_conv2d_transpose_op import conv2dtranspose_forward_naive, TestConv2DTransposeOp
2423

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def executor_main(self):
145145
def pe_main(self):
146146
image, label, loss = simple_fc_net()
147147
loss.persistable = False
148-
persistables, non_persistables = get_persistables_and_non_persistables(
148+
persitables, non_persistables = get_persistables_and_non_persistables(
149149
fluid.default_main_program(), [loss.name])
150150

151151
exe = fluid.Executor(self.place)

python/paddle/fluid/tests/unittests/xpu/test_pool2d_op_xpu.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import paddle.fluid as fluid
2626
from paddle.fluid import Program, program_guard
2727
import paddle
28-
from test_pool2d_op import adaptive_start_index, adaptive_end_index
2928

3029
paddle.enable_static()
3130

python/paddle/optimizer/lr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ def step(self, metrics, epoch=None):
13491349
if isinstance(metrics, (Tensor, numpy.ndarray)):
13501350
assert len(metrics.shape) == 1 and metrics.shape[0] == 1, "the metrics.shape " \
13511351
"should be (1L,), but the current metrics.shape is {}. Maybe that " \
1352-
"you should call paddle.mean to process it first.".format(metrics.shape)
1352+
"you should call paddle.mean to process it first.".format(loss.shape)
13531353
elif not isinstance(metrics,
13541354
(int, float, numpy.float32, numpy.float64)):
13551355
raise TypeError(

python/paddle/optimizer/optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,11 @@ def set_state_dict(self, state_dict):
309309

310310
assert model_np.shape == load_para_np.shape, \
311311
"Parameter shape not match, Dygraph Parameter [ {} ] need tensor with shape {} but load tensor with shape {}".format(
312-
model_np.name, model_np.shape, load_para_np.shape)
312+
item.name, model_np.shape, load_para_np.shape)
313313

314314
assert model_np.dtype == load_para_np.dtype, \
315315
"Parameter dtype not match, Dygraph Parameter [ {} ] need tensor with dtype {} but load tensor with dtype {}".format(
316-
model_np.name, model_np.dtype, load_para_np.dtype)
316+
item.name, model_np.dtype, load_para_np.dtype)
317317

318318
tensor.set(load_para_np, framework._current_expected_place())
319319

python/paddle/tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class TestModel(unittest.TestCase):
126126
@classmethod
127127
def setUpClass(cls):
128128
if not fluid.is_compiled_with_cuda():
129-
cls.skipTest('module not tested when ONLY_CPU compling')
129+
self.skipTest('module not tested when ONLY_CPU compling')
130130
cls.device = paddle.set_device('gpu')
131131
fluid.enable_dygraph(cls.device)
132132

python/paddle/text/datasets/wmt14.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from __future__ import print_function
1616

17-
import six
1817
import tarfile
1918
import numpy as np
2019
import gzip

0 commit comments

Comments
 (0)