未验证 提交 4b9430a1 编写于 作者: J Jiangxinz 提交者: GitHub

fix undef val (#33562)

上级 c269a160
...@@ -25,6 +25,7 @@ import subprocess ...@@ -25,6 +25,7 @@ import subprocess
from contextlib import closing from contextlib import closing
import socket import socket
from paddle.fluid import core from paddle.fluid import core
from distutils.util import strtobool
__all__ = [ #noqa __all__ = [ #noqa
'get_host_name_ip', 'get_host_name_ip',
...@@ -384,7 +385,7 @@ def add_arguments(argname, type, default, help, argparser, **kwargs): ...@@ -384,7 +385,7 @@ def add_arguments(argname, type, default, help, argparser, **kwargs):
add_argument("name", str, "Jonh", "User name.", parser) add_argument("name", str, "Jonh", "User name.", parser)
args = parser.parse_args() args = parser.parse_args()
""" """
type = distutils.util.strtobool if type == bool else type type = strtobool if type == bool else type
argparser.add_argument( argparser.add_argument(
"--" + argname, "--" + argname,
default=default, default=default,
......
...@@ -78,7 +78,6 @@ def default_collate_fn(batch): ...@@ -78,7 +78,6 @@ def default_collate_fn(batch):
raise TypeError("batch data con only contains: tensor, numpy.ndarray, " raise TypeError("batch data con only contains: tensor, numpy.ndarray, "
"dict, list, number, but got {}".format(type(sample))) "dict, list, number, but got {}".format(type(sample)))
return outputs
def default_convert_fn(batch): def default_convert_fn(batch):
......
...@@ -1564,7 +1564,7 @@ class DGCMomentumOptimizer(Optimizer): ...@@ -1564,7 +1564,7 @@ class DGCMomentumOptimizer(Optimizer):
assert isinstance( assert isinstance(
num_trainers, int num_trainers, int
), "The type of num_trainers should be 'int', but received %s" % type( ), "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!" assert num_trainers > 0, "The value of num_trainers should be greater than 0!"
self._num_trainers = num_trainers self._num_trainers = num_trainers
......
...@@ -18,7 +18,7 @@ import unittest ...@@ -18,7 +18,7 @@ import unittest
import numpy as np import numpy as np
import paddle.fluid.core as core import paddle.fluid.core as core
from paddle.fluid.tests.unittests.op_test import OpTest 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 from paddle.fluid.tests.unittests.test_conv2d_transpose_op import conv2dtranspose_forward_naive, TestConv2DTransposeOp
......
...@@ -145,7 +145,7 @@ class TestExecutor(unittest.TestCase): ...@@ -145,7 +145,7 @@ class TestExecutor(unittest.TestCase):
def pe_main(self): def pe_main(self):
image, label, loss = simple_fc_net() image, label, loss = simple_fc_net()
loss.persistable = False 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]) fluid.default_main_program(), [loss.name])
exe = fluid.Executor(self.place) exe = fluid.Executor(self.place)
......
...@@ -24,6 +24,7 @@ import paddle.fluid.core as core ...@@ -24,6 +24,7 @@ import paddle.fluid.core as core
from op_test_xpu import XPUOpTest from op_test_xpu import XPUOpTest
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid import Program, program_guard from paddle.fluid import Program, program_guard
from test_pool2d_op import adaptive_start_index, adaptive_end_index
import paddle import paddle
paddle.enable_static() paddle.enable_static()
......
...@@ -1349,7 +1349,7 @@ class ReduceOnPlateau(LRScheduler): ...@@ -1349,7 +1349,7 @@ class ReduceOnPlateau(LRScheduler):
if isinstance(metrics, (Tensor, numpy.ndarray)): if isinstance(metrics, (Tensor, numpy.ndarray)):
assert len(metrics.shape) == 1 and metrics.shape[0] == 1, "the metrics.shape " \ assert len(metrics.shape) == 1 and metrics.shape[0] == 1, "the metrics.shape " \
"should be (1L,), but the current metrics.shape is {}. Maybe that " \ "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, elif not isinstance(metrics,
(int, float, numpy.float32, numpy.float64)): (int, float, numpy.float32, numpy.float64)):
raise TypeError( raise TypeError(
......
...@@ -309,11 +309,11 @@ class Optimizer(object): ...@@ -309,11 +309,11 @@ class Optimizer(object):
assert model_np.shape == load_para_np.shape, \ assert model_np.shape == load_para_np.shape, \
"Parameter shape not match, Dygraph Parameter [ {} ] need tensor with shape {} but load tensor with shape {}".format( "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, \ assert model_np.dtype == load_para_np.dtype, \
"Parameter dtype not match, Dygraph Parameter [ {} ] need tensor with dtype {} but load tensor with dtype {}".format( "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()) tensor.set(load_para_np, framework._current_expected_place())
......
...@@ -126,7 +126,7 @@ class TestModel(unittest.TestCase): ...@@ -126,7 +126,7 @@ class TestModel(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not fluid.is_compiled_with_cuda(): 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') cls.device = paddle.set_device('gpu')
fluid.enable_dygraph(cls.device) fluid.enable_dygraph(cls.device)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册