Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
99f5907e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
99f5907e
编写于
1月 17, 2020
作者:
S
songyouwei
提交者:
hong
1月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix layer & dygraph circular dependent (#22334)
* fix circular dependent * try import layers.nn from dygraph test=develop
上级
4dec1599
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
14 addition
and
18 deletion
+14
-18
python/paddle/fluid/dygraph/nn.py
python/paddle/fluid/dygraph/nn.py
+2
-1
python/paddle/fluid/dygraph_utils.py
python/paddle/fluid/dygraph_utils.py
+2
-2
python/paddle/fluid/layers/learning_rate_scheduler.py
python/paddle/fluid/layers/learning_rate_scheduler.py
+9
-9
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+1
-6
未找到文件。
python/paddle/fluid/dygraph/nn.py
浏览文件 @
99f5907e
...
...
@@ -17,7 +17,8 @@ from __future__ import print_function
from
six.moves
import
reduce
from
..
import
core
from
..layers
import
utils
from
..dygraph
import
dygraph_utils
from
..layers
import
nn
from
..
import
dygraph_utils
from
.
import
layers
from
..framework
import
Variable
,
in_dygraph_mode
,
OpProtoHolder
,
Parameter
,
_dygraph_tracer
,
_varbase_creator
from
..param_attr
import
ParamAttr
...
...
python/paddle/fluid/dygraph
/dygraph
_utils.py
→
python/paddle/fluid/dygraph_utils.py
浏览文件 @
99f5907e
...
...
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
.
.
import
core
from
.
.
framework
import
dygraph_only
from
.
import
core
from
.framework
import
dygraph_only
@
dygraph_only
...
...
python/paddle/fluid/layers/learning_rate_scheduler.py
浏览文件 @
99f5907e
...
...
@@ -32,7 +32,7 @@ from . import tensor
from
..initializer
import
init_on_cpu
from
..framework
import
default_main_program
,
Parameter
,
unique_name
,
name_scope
from
..framework
import
Variable
from
..
dygraph
import
base
as
imperative_bas
e
from
..
framework
import
in_dygraph_mod
e
from
..dygraph
import
learning_rate_scheduler
as
imperate_lr
__all__
=
[
...
...
@@ -88,7 +88,7 @@ def noam_decay(d_model, warmup_steps):
warmup_steps)
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
NoamDecay
(
d_model
,
warmup_steps
)
return
decay
else
:
...
...
@@ -143,7 +143,7 @@ def exponential_decay(learning_rate, decay_steps, decay_rate, staircase=False):
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
ExponentialDecay
(
learning_rate
,
decay_steps
,
decay_rate
,
staircase
)
return
decay
...
...
@@ -199,7 +199,7 @@ def natural_exp_decay(learning_rate, decay_steps, decay_rate, staircase=False):
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
NaturalExpDecay
(
learning_rate
,
decay_steps
,
decay_rate
,
staircase
)
return
decay
...
...
@@ -255,7 +255,7 @@ def inverse_time_decay(learning_rate, decay_steps, decay_rate, staircase=False):
staircase=True))
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
InverseTimeDecay
(
learning_rate
,
decay_steps
,
decay_rate
,
staircase
)
return
decay
...
...
@@ -311,7 +311,7 @@ def polynomial_decay(learning_rate,
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
PolynomialDecay
(
learning_rate
,
decay_steps
,
end_learning_rate
,
power
,
cycle
)
return
decay
...
...
@@ -380,7 +380,7 @@ def piecewise_decay(boundaries, values):
if
len
(
values
)
-
len
(
boundaries
)
!=
1
:
raise
ValueError
(
"len(values) - len(boundaries) should be 1"
)
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
PiecewiseDecay
(
boundaries
,
values
,
0
)
return
decay
else
:
...
...
@@ -444,7 +444,7 @@ def cosine_decay(learning_rate, step_each_epoch, epochs):
"""
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
decay
=
imperate_lr
.
CosineDecay
(
learning_rate
,
step_each_epoch
,
epochs
)
return
decay
...
...
@@ -520,7 +520,7 @@ def linear_lr_warmup(learning_rate, warmup_steps, start_lr, end_lr):
linear_step
=
float
(
end_lr
)
-
float
(
start_lr
)
with
default_main_program
().
_lr_schedule_guard
():
if
i
mperative_base
.
enabled
():
if
i
n_dygraph_mode
():
lr
=
imperate_lr
.
LinearLrWarmup
(
learning_rate
,
warmup_steps
,
start_lr
,
end_lr
)
return
lr
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
99f5907e
...
...
@@ -25,8 +25,7 @@ import inspect
from ..layer_helper import LayerHelper
from ..initializer import Normal, Constant, NumpyArrayInitializer
from ..framework import Variable, OpProtoHolder, in_dygraph_mode, dygraph_only, _dygraph_tracer, default_main_program
from ..dygraph import base
from ..dygraph import dygraph_utils
from .. import dygraph_utils
from ..param_attr import ParamAttr
from .layer_function_generator import autodoc, templatedoc, _generate_doc_string_
from .tensor import concat, assign, fill_constant, zeros
...
...
@@ -34,7 +33,6 @@ from . import utils
from .. import unique_name
from functools import reduce
from .. import core
from ..dygraph import layers
from ..data_feeder import convert_dtype, check_type_and_dtype, check_type, check_dtype
__all__ = [
...
...
@@ -10276,9 +10274,6 @@ def _elementwise_op(helper):
op_type = helper.layer_type
x = helper.kwargs.get('x', None)
y = helper.kwargs.get('y', None)
if in_dygraph_mode():
x = base.to_variable(x)
y = base.to_variable(y)
assert x is not None, 'x cannot be None in {}'.format(op_type)
assert y is not None, 'y cannot be None in {}'.format(op_type)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录