Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
99ec2c16
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
99ec2c16
编写于
11月 16, 2022
作者:
H
HongyuJia
提交者:
GitHub
11月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Clean fluid] Clean fluid elementwise_min (part1) (#48033)
* clean fluid elementwise_min * fix elementwise_min op testcase
上级
29a0987a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
10 addition
and
16 deletion
+10
-16
python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py
...e/distributed/fleet/meta_optimizers/localsgd_optimizer.py
+1
-1
python/paddle/fluid/dygraph/learning_rate_scheduler.py
python/paddle/fluid/dygraph/learning_rate_scheduler.py
+1
-3
python/paddle/fluid/layers/learning_rate_scheduler.py
python/paddle/fluid/layers/learning_rate_scheduler.py
+3
-6
python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
...dle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_min_op.py
+2
-1
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+2
-4
未找到文件。
python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py
浏览文件 @
99ec2c16
...
...
@@ -465,7 +465,7 @@ class AdaptiveLocalSGDOptimizer(MetaOptimizerBase):
min_local_steps
=
layers
.
fill_constant
(
shape
=
[
1
],
dtype
=
'int64'
,
value
=
1
)
next_local_steps
=
layers
.
elementwise_min
(
next_local_steps
=
paddle
.
minimum
(
next_local_steps
,
max_local_steps
)
next_local_steps
=
paddle
.
maximum
(
...
...
python/paddle/fluid/dygraph/learning_rate_scheduler.py
浏览文件 @
99ec2c16
...
...
@@ -680,9 +680,7 @@ class NoamDecay(LearningRateDecay):
a
=
self
.
create_lr_var
(
self
.
step_num
**-
0.5
)
b
=
self
.
create_lr_var
((
self
.
warmup_steps
**-
1.5
)
*
self
.
step_num
)
lr_value
=
(
self
.
learning_rate
*
(
self
.
d_model
**-
0.5
)
*
layers
.
elementwise_min
(
a
,
b
)
self
.
learning_rate
*
(
self
.
d_model
**-
0.5
)
*
paddle
.
minimum
(
a
,
b
)
)
return
lr_value
...
...
python/paddle/fluid/layers/learning_rate_scheduler.py
浏览文件 @
99ec2c16
...
...
@@ -23,6 +23,7 @@ strategy according to this module.
import
math
import
numbers
import
paddle
from
.
import
control_flow
from
.
import
nn
from
.
import
ops
...
...
@@ -109,9 +110,7 @@ def noam_decay(d_model, warmup_steps, learning_rate=1.0):
a
=
global_step
**-
0.5
b
=
(
warmup_steps
**-
1.5
)
*
global_step
lr_value
=
(
learning_rate
*
(
d_model
**-
0.5
)
*
nn
.
elementwise_min
(
a
,
b
)
)
lr_value
=
learning_rate
*
(
d_model
**-
0.5
)
*
paddle
.
minimum
(
a
,
b
)
return
lr_value
...
...
@@ -364,9 +363,7 @@ def polynomial_decay(
decay_steps_var
=
tensor
.
fill_constant
(
shape
=
[
1
],
dtype
=
'float32'
,
value
=
float
(
decay_steps
)
)
global_step
=
nn
.
elementwise_min
(
x
=
global_step
,
y
=
decay_steps_var
)
global_step
=
paddle
.
minimum
(
x
=
global_step
,
y
=
decay_steps_var
)
decayed_lr
=
(
learning_rate
-
end_learning_rate
)
*
(
(
1
-
global_step
/
decay_steps
)
**
power
...
...
python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
浏览文件 @
99ec2c16
...
...
@@ -140,7 +140,7 @@ class TestDiv(TestMul):
class
TestMin
(
TestMul
):
def
set_test_op
(
self
):
self
.
op
=
paddle
.
fluid
.
layers
.
elementwise_min
self
.
op
=
paddle
.
minimum
class
TestMax
(
TestMul
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
浏览文件 @
99ec2c16
...
...
@@ -18,6 +18,7 @@ from op_test import OpTest, skip_check_grad_ci
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
from
paddle
import
_legacy_C_ops
paddle
.
enable_static
()
...
...
@@ -213,7 +214,7 @@ class TestElementwiseMinOpFP16(unittest.TestCase):
y
=
paddle
.
to_tensor
(
y_np
)
x
.
stop_gradient
=
False
y
.
stop_gradient
=
False
z
=
fluid
.
layers
.
elementwise_min
(
x
,
y
,
axis
)
z
=
_legacy_C_ops
.
elementwise_min
(
x
,
y
,
'axis'
,
axis
)
x_g
,
y_g
=
paddle
.
grad
([
z
],
[
x
,
y
])
return
(
z
.
numpy
().
astype
(
dtype
),
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
99ec2c16
...
...
@@ -649,14 +649,12 @@ class TestLayer(LayerTest):
with
self
.
dynamic_graph
():
with
_test_eager_guard
():
min_eager_ret
=
layers
.
elementwise_min
(
to_variable
(
n
),
to_variable
(
n2
)
)
min_eager_ret
=
paddle
.
minimum
(
to_variable
(
n
),
to_variable
(
n2
))
max_eager_ret
=
paddle
.
maximum
(
to_variable
(
n
),
to_variable
(
n2
))
min_eager_ret_value
=
min_eager_ret
.
numpy
()
max_eager_ret_value
=
max_eager_ret
.
numpy
()
min_ret
=
layers
.
elementwise_min
(
to_variable
(
n
),
to_variable
(
n2
))
min_ret
=
paddle
.
minimum
(
to_variable
(
n
),
to_variable
(
n2
))
max_ret
=
paddle
.
maximum
(
to_variable
(
n
),
to_variable
(
n2
))
min_ret_value
=
min_ret
.
numpy
()
max_ret_value
=
max_ret
.
numpy
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录