diff --git a/python/paddle/distributed/utils.py b/python/paddle/distributed/utils.py index 9c56534095cb2776f07942abf35326d07d25d97c..447c059537ba3f2ba728f1acc76748f8a9154fca 100644 --- a/python/paddle/distributed/utils.py +++ b/python/paddle/distributed/utils.py @@ -25,6 +25,7 @@ import subprocess from contextlib import closing import socket from paddle.fluid import core +from distutils.util import strtobool __all__ = [ #noqa 'get_host_name_ip', @@ -384,7 +385,7 @@ def add_arguments(argname, type, default, help, argparser, **kwargs): add_argument("name", str, "Jonh", "User name.", parser) args = parser.parse_args() """ - type = distutils.util.strtobool if type == bool else type + type = strtobool if type == bool else type argparser.add_argument( "--" + argname, default=default, diff --git a/python/paddle/fluid/dataloader/collate.py b/python/paddle/fluid/dataloader/collate.py index 8e90b308b393ed04b295eb80ab6272c12f807391..eaaf4cc2d9f62b491b6ee8f9db2c93f0db45a673 100644 --- a/python/paddle/fluid/dataloader/collate.py +++ b/python/paddle/fluid/dataloader/collate.py @@ -78,7 +78,6 @@ def default_collate_fn(batch): raise TypeError("batch data con only contains: tensor, numpy.ndarray, " "dict, list, number, but got {}".format(type(sample))) - return outputs def default_convert_fn(batch): diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index e2ddc20b8f96b9c28cccd403bd93a4abe634bc95..b1b6c95ea33604c1629f55444a8a1968023e3faa 100755 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -14,6 +14,7 @@ from __future__ import print_function +import warnings import numpy as np import six import os @@ -21,6 +22,7 @@ import logging from collections import defaultdict import paddle +import paddle.fluid as fluid from paddle.fluid.distribute_lookup_table import find_distributed_lookup_table from paddle.fluid.framework import Program, Variable, name_scope, default_main_program, default_startup_program, device_guard @@ -1469,7 +1471,7 @@ class DGCMomentumOptimizer(Optimizer): assert isinstance( num_trainers, int ), "The type of num_trainers should be 'int', but received %s" % type( - value) + num_trainers) assert num_trainers > 0, "The value of num_trainers should be greater than 0!" self._num_trainers = num_trainers diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py index f31ddf921f819c9b377d950bff8c7a77ea352cae..b473d2643d3788fc38318f33d13a96211616a881 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py @@ -18,6 +18,7 @@ import unittest import numpy as np import paddle.fluid.core as core from paddle.fluid.tests.unittests.op_test import OpTest +from paddle import enable_static from paddle.fluid.tests.unittests.test_conv2d_transpose_op import conv2dtranspose_forward_naive, TestConv2DTransposeOp diff --git a/python/paddle/fluid/tests/unittests/test_eager_deletion_delete_vars.py b/python/paddle/fluid/tests/unittests/test_eager_deletion_delete_vars.py index 835f693ab6d7d8c63dfea655ceca29ce6b056e61..1590d866b1c73c88ed2c3fbd1fceb90831954b13 100644 --- a/python/paddle/fluid/tests/unittests/test_eager_deletion_delete_vars.py +++ b/python/paddle/fluid/tests/unittests/test_eager_deletion_delete_vars.py @@ -145,7 +145,7 @@ class TestExecutor(unittest.TestCase): def pe_main(self): image, label, loss = simple_fc_net() loss.persistable = False - persitables, non_persistables = get_persistables_and_non_persistables( + persistables, non_persistables = get_persistables_and_non_persistables( fluid.default_main_program(), [loss.name]) exe = fluid.Executor(self.place) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_pool2d_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_pool2d_op_xpu.py index bebb5c762649145cab666633ac91371ab679f551..53a91af3a716ba1f48446923e71b3f34d6df3c06 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_pool2d_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_pool2d_op_xpu.py @@ -25,6 +25,7 @@ from op_test_xpu import XPUOpTest import paddle.fluid as fluid from paddle.fluid import Program, program_guard import paddle +from test_pool2d_op import adaptive_start_index, adaptive_end_index paddle.enable_static() diff --git a/python/paddle/optimizer/lr.py b/python/paddle/optimizer/lr.py index 7da933a9b72798db2606242c02065b66b333812f..db4e80d8d9a59b4de1d926fb95cdd9dfde696387 100644 --- a/python/paddle/optimizer/lr.py +++ b/python/paddle/optimizer/lr.py @@ -1349,7 +1349,7 @@ class ReduceOnPlateau(LRScheduler): if isinstance(metrics, (Tensor, numpy.ndarray)): assert len(metrics.shape) == 1 and metrics.shape[0] == 1, "the metrics.shape " \ "should be (1L,), but the current metrics.shape is {}. Maybe that " \ - "you should call paddle.mean to process it first.".format(loss.shape) + "you should call paddle.mean to process it first.".format(metrics.shape) elif not isinstance(metrics, (int, float, numpy.float32, numpy.float64)): raise TypeError( diff --git a/python/paddle/optimizer/optimizer.py b/python/paddle/optimizer/optimizer.py index 2cdf1d0d28e00e8bdfcb0db429c3678864606262..93b618b7c9edc0f2efde1badcb691d6774e0b666 100644 --- a/python/paddle/optimizer/optimizer.py +++ b/python/paddle/optimizer/optimizer.py @@ -309,11 +309,11 @@ class Optimizer(object): assert model_np.shape == load_para_np.shape, \ "Parameter shape not match, Dygraph Parameter [ {} ] need tensor with shape {} but load tensor with shape {}".format( - item.name, model_np.shape, load_para_np.shape) + model_np.name, model_np.shape, load_para_np.shape) assert model_np.dtype == load_para_np.dtype, \ "Parameter dtype not match, Dygraph Parameter [ {} ] need tensor with dtype {} but load tensor with dtype {}".format( - item.name, model_np.dtype, load_para_np.dtype) + model_np.name, model_np.dtype, load_para_np.dtype) tensor.set(load_para_np, framework._current_expected_place()) diff --git a/python/paddle/tests/test_model.py b/python/paddle/tests/test_model.py index ae574a8241bfffccea7c9d0e7fe71a83a710e778..0ced69c0f2ea9620918c3cd0e3b970a1226a3863 100644 --- a/python/paddle/tests/test_model.py +++ b/python/paddle/tests/test_model.py @@ -126,7 +126,7 @@ class TestModel(unittest.TestCase): @classmethod def setUpClass(cls): if not fluid.is_compiled_with_cuda(): - self.skipTest('module not tested when ONLY_CPU compling') + cls.skipTest('module not tested when ONLY_CPU compling') cls.device = paddle.set_device('gpu') fluid.enable_dygraph(cls.device) diff --git a/python/paddle/text/datasets/wmt14.py b/python/paddle/text/datasets/wmt14.py index 424a564216d19072d3927358fc1ff9c3a3af307b..a50b9e81aac6d6d19d67c3de215361ed7ebdd3b8 100644 --- a/python/paddle/text/datasets/wmt14.py +++ b/python/paddle/text/datasets/wmt14.py @@ -14,6 +14,7 @@ from __future__ import print_function +import six import tarfile import numpy as np import gzip