From 1b83de2eff362117507794ffaab6f6c29ba07809 Mon Sep 17 00:00:00 2001 From: zhiboniu <31800336+zhiboniu@users.noreply.github.com> Date: Fri, 23 Apr 2021 15:54:52 +0800 Subject: [PATCH] update 2.0 public api in optimizer (#31944) --- python/paddle/optimizer/__init__.py | 38 +++++++++++++++++----------- python/paddle/optimizer/adadelta.py | 2 -- python/paddle/optimizer/adagrad.py | 2 -- python/paddle/optimizer/adam.py | 2 -- python/paddle/optimizer/adamax.py | 2 -- python/paddle/optimizer/adamw.py | 2 -- python/paddle/optimizer/lamb.py | 2 -- python/paddle/optimizer/lr.py | 17 ++++++++++--- python/paddle/optimizer/momentum.py | 1 - python/paddle/optimizer/optimizer.py | 2 -- python/paddle/optimizer/rmsprop.py | 2 -- python/paddle/optimizer/sgd.py | 1 - 12 files changed, 36 insertions(+), 37 deletions(-) diff --git a/python/paddle/optimizer/__init__.py b/python/paddle/optimizer/__init__.py index edebfdfcf37..07d2935bc76 100644 --- a/python/paddle/optimizer/__init__.py +++ b/python/paddle/optimizer/__init__.py @@ -12,19 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -__all__ = [ - 'Optimizer', 'Adagrad', 'Adam', 'AdamW', 'Adamax', 'RMSProp', 'Adadelta', - 'SGD', 'Momentum', 'Lamb', 'lr' -] +from .optimizer import Optimizer # noqa: F401 +from .adagrad import Adagrad # noqa: F401 +from .adam import Adam # noqa: F401 +from .adamw import AdamW # noqa: F401 +from .adamax import Adamax # noqa: F401 +from .rmsprop import RMSProp # noqa: F401 +from .adadelta import Adadelta # noqa: F401 +from .sgd import SGD # noqa: F401 +from .momentum import Momentum # noqa: F401 +from .lamb import Lamb # noqa: F401 +from . import lr # noqa: F401 -from .optimizer import Optimizer -from .adagrad import Adagrad -from .adam import Adam -from .adamw import AdamW -from .adamax import Adamax -from .rmsprop import RMSProp -from .adadelta import Adadelta -from .sgd import SGD -from .momentum import Momentum -from .lamb import Lamb -from . import lr +__all__ = [ #noqa + 'Optimizer', + 'Adagrad', + 'Adam', + 'AdamW', + 'Adamax', + 'RMSProp', + 'Adadelta', + 'SGD', + 'Momentum', + 'Lamb' +] diff --git a/python/paddle/optimizer/adadelta.py b/python/paddle/optimizer/adadelta.py index e921eda41cf..42e2a5851c2 100644 --- a/python/paddle/optimizer/adadelta.py +++ b/python/paddle/optimizer/adadelta.py @@ -17,8 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable, name_scope -__all__ = ["Adadelta"] - class Adadelta(Optimizer): r""" diff --git a/python/paddle/optimizer/adagrad.py b/python/paddle/optimizer/adagrad.py index ec14828e693..d3077949ff0 100644 --- a/python/paddle/optimizer/adagrad.py +++ b/python/paddle/optimizer/adagrad.py @@ -17,8 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable -__all__ = ["Adagrad"] - class Adagrad(Optimizer): r""" diff --git a/python/paddle/optimizer/adam.py b/python/paddle/optimizer/adam.py index 0cafbda893d..dcedf4fc502 100644 --- a/python/paddle/optimizer/adam.py +++ b/python/paddle/optimizer/adam.py @@ -24,8 +24,6 @@ from ..fluid.dygraph import base as imperative_base import paddle -__all__ = ["Adam"] - class Adam(Optimizer): r""" diff --git a/python/paddle/optimizer/adamax.py b/python/paddle/optimizer/adamax.py index 4a6c2278a46..9d5adf0bba5 100644 --- a/python/paddle/optimizer/adamax.py +++ b/python/paddle/optimizer/adamax.py @@ -17,8 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable, name_scope -__all__ = ["Adamax"] - class Adamax(Optimizer): r""" diff --git a/python/paddle/optimizer/adamw.py b/python/paddle/optimizer/adamw.py index 32645720c4f..eb88a48f303 100644 --- a/python/paddle/optimizer/adamw.py +++ b/python/paddle/optimizer/adamw.py @@ -19,8 +19,6 @@ from ..fluid import framework from ..fluid.dygraph import base as imperative_base import paddle -__all__ = ['AdamW'] - class AdamW(Adam): r""" diff --git a/python/paddle/optimizer/lamb.py b/python/paddle/optimizer/lamb.py index a692f59de5b..bab130ec590 100644 --- a/python/paddle/optimizer/lamb.py +++ b/python/paddle/optimizer/lamb.py @@ -17,8 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable -__all__ = ["Lamb"] - class Lamb(Optimizer): r""" diff --git a/python/paddle/optimizer/lr.py b/python/paddle/optimizer/lr.py index 484b4fb7246..f269bffc75e 100644 --- a/python/paddle/optimizer/lr.py +++ b/python/paddle/optimizer/lr.py @@ -17,10 +17,19 @@ import numpy import warnings from paddle import Tensor -__all__ = [ - 'LRScheduler', 'NoamDecay', 'PiecewiseDecay', 'NaturalExpDecay', - 'InverseTimeDecay', 'PolynomialDecay', 'LinearWarmup', 'ExponentialDecay', - 'MultiStepDecay', 'StepDecay', 'LambdaDecay', 'ReduceOnPlateau', +__all__ = [ #noqa + 'LRScheduler', + 'NoamDecay', + 'PiecewiseDecay', + 'NaturalExpDecay', + 'InverseTimeDecay', + 'PolynomialDecay', + 'LinearWarmup', + 'ExponentialDecay', + 'MultiStepDecay', + 'StepDecay', + 'LambdaDecay', + 'ReduceOnPlateau', 'CosineAnnealingDecay' ] diff --git a/python/paddle/optimizer/momentum.py b/python/paddle/optimizer/momentum.py index 111b2720c86..932a4ad100e 100644 --- a/python/paddle/optimizer/momentum.py +++ b/python/paddle/optimizer/momentum.py @@ -21,7 +21,6 @@ from ..fluid import unique_name from ..fluid import layers import paddle.fluid as fluid from paddle.fluid.regularizer import L2DecayRegularizer -__all__ = ["Momentum"] class Momentum(Optimizer): diff --git a/python/paddle/optimizer/optimizer.py b/python/paddle/optimizer/optimizer.py index 0d44df59012..a050852728d 100644 --- a/python/paddle/optimizer/optimizer.py +++ b/python/paddle/optimizer/optimizer.py @@ -42,8 +42,6 @@ from ..fluid.wrapped_decorator import signature_safe_contextmanager from .. import compat as cpt from .lr import LRScheduler -__all__ = ['Optimizer'] - class Optimizer(object): r"""Optimizer Base class. diff --git a/python/paddle/optimizer/rmsprop.py b/python/paddle/optimizer/rmsprop.py index 12825bb7813..7146b7d8993 100644 --- a/python/paddle/optimizer/rmsprop.py +++ b/python/paddle/optimizer/rmsprop.py @@ -17,8 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable -__all__ = ["RMSProp"] - class RMSProp(Optimizer): r""" diff --git a/python/paddle/optimizer/sgd.py b/python/paddle/optimizer/sgd.py index b2937ff1620..fc208519a2e 100644 --- a/python/paddle/optimizer/sgd.py +++ b/python/paddle/optimizer/sgd.py @@ -17,7 +17,6 @@ from ..fluid import core from ..fluid import framework from ..fluid.framework import Variable, name_scope from ..fluid.dygraph import no_grad -__all__ = ["SGD"] class SGD(Optimizer): -- GitLab