From 68c1fe8c41a3c51347a4b9c670b92cb079e62de8 Mon Sep 17 00:00:00 2001 From: Jiangxinz Date: Thu, 24 Jun 2021 14:44:47 +0800 Subject: [PATCH] fix undef var (#33692) --- .../distributed/fleet/meta_optimizers/localsgd_optimizer.py | 1 + python/paddle/fluid/dataloader/flat.py | 2 +- python/paddle/fluid/distributed/fleet.py | 1 + python/paddle/fluid/tests/unittests/test_group_norm_op.py | 2 +- python/paddle/optimizer/momentum.py | 2 ++ 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py b/python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py index 3340672e0f9..9052111d22c 100644 --- a/python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py +++ b/python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py @@ -16,6 +16,7 @@ from __future__ import print_function import paddle from paddle.fluid import program_guard, layers, default_main_program +from paddle.fluid import default_startup_program from .meta_optimizer_base import MetaOptimizerBase from .common import OpRole, OP_ROLE_KEY, CollectiveHelper, is_update_op diff --git a/python/paddle/fluid/dataloader/flat.py b/python/paddle/fluid/dataloader/flat.py index db3a725ece0..32c8ef02dd9 100644 --- a/python/paddle/fluid/dataloader/flat.py +++ b/python/paddle/fluid/dataloader/flat.py @@ -120,7 +120,7 @@ def _restore_batch(flat_batch, structure): elif isinstance(field, (Sequence, Mapping)): field_idx = _restore(structure[k], field_idx) else: - raise TypeError("wrong flat data type: {}".format(type(batch))) + raise TypeError("wrong flat data type: {}".format(type(structure))) return field_idx diff --git a/python/paddle/fluid/distributed/fleet.py b/python/paddle/fluid/distributed/fleet.py index 8f3d2defb9f..cd261195685 100644 --- a/python/paddle/fluid/distributed/fleet.py +++ b/python/paddle/fluid/distributed/fleet.py @@ -13,6 +13,7 @@ import sys from .. import core from . import ps_instance +from google.protobuf import text_format __all__ = ['Fleet'] diff --git a/python/paddle/fluid/tests/unittests/test_group_norm_op.py b/python/paddle/fluid/tests/unittests/test_group_norm_op.py index 0ac8def94d0..61a51d9b5dd 100644 --- a/python/paddle/fluid/tests/unittests/test_group_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_group_norm_op.py @@ -46,7 +46,7 @@ class TestGroupNormOpError(unittest.TestCase): def test_x_type(): input = np.random.random(2, 100, 3, 5).astype('float32') - goups = 2 + groups = 2 fluid.layers.group_norm(input, groups) self.assertRaises(TypeError, test_x_type) diff --git a/python/paddle/optimizer/momentum.py b/python/paddle/optimizer/momentum.py index 85c5c60a34c..38ca21a3df4 100644 --- a/python/paddle/optimizer/momentum.py +++ b/python/paddle/optimizer/momentum.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + from .optimizer import Optimizer from ..fluid import core from ..fluid import framework -- GitLab