Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
676e4b35
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看板
未验证
提交
676e4b35
编写于
12月 16, 2022
作者:
K
kangguangli
提交者:
GitHub
12月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove api `fluid.layers.relu` and its reference in sample code and unit tests (#49097)
上级
effd51c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
6 addition
and
52 deletion
+6
-52
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+0
-46
python/paddle/fluid/reader.py
python/paddle/fluid/reader.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py
...d/tests/unittests/dygraph_to_static/ifelse_simple_func.py
+3
-3
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
...dle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
+2
-2
未找到文件。
python/paddle/fluid/layers/nn.py
浏览文件 @
676e4b35
...
...
@@ -73,7 +73,6 @@ __all__ = [
'autoincreased_step_counter'
,
'unsqueeze'
,
'lod_reset'
,
'relu'
,
'clip'
,
'clip_by_norm'
,
'mul'
,
...
...
@@ -1826,51 +1825,6 @@ def lod_reset(x, y=None, target_lod=None):
return
out
@
deprecated
(
since
=
"2.0.0"
,
update_to
=
"paddle.nn.functional.relu"
)
def
relu
(
x
,
name
=
None
):
"""
${comment}
Args:
x(Variable): ${x_comment}
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
Returns:
Variable: ${out_comment}
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
in1 = np.array([[-1,0],[1,2.6]])
with fluid.dygraph.guard():
x1 = fluid.dygraph.to_variable(in1)
out1 = fluid.layers.relu(x1)
print(out1.numpy())
# [[0. 0. ]
# [1. 2.6]]"""
if
in_dygraph_mode
():
return
_C_ops
.
relu
(
x
)
if
_in_legacy_dygraph
():
return
_legacy_C_ops
.
relu
(
x
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'relu'
)
inputs
=
{
'X'
:
[
x
]}
helper
=
LayerHelper
(
'relu'
,
**
locals
())
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
)
helper
.
append_op
(
type
=
"relu"
,
inputs
=
{
"X"
:
helper
.
input
(
'x'
)},
outputs
=
{
"Out"
:
out
}
)
return
out
def
_logical_op
(
op_name
,
x
,
y
,
out
=
None
,
name
=
None
,
binary_op
=
True
):
if
_non_static_mode
():
op
=
getattr
(
_legacy_C_ops
,
op_name
)
...
...
python/paddle/fluid/reader.py
浏览文件 @
676e4b35
...
...
@@ -1810,7 +1810,7 @@ class PyReader(DataLoaderBase):
paddle.batch(user_defined_reader, batch_size=BATCH_SIZE),
place)
for image, label in py_reader():
relu =
fluid.layers
.relu(image)
relu =
paddle.nn.functional
.relu(image)
"""
def
__init__
(
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py
浏览文件 @
676e4b35
...
...
@@ -62,7 +62,7 @@ def dyfunc_with_if_else2(x, col=100):
# col = -1
col
=
fluid
.
layers
.
fill_constant
(
shape
=
[
1
],
value
=-
1
,
dtype
=
"int64"
)
if
paddle
.
mean
(
x
).
numpy
()[
0
]
>
x
.
numpy
()[
row
][
col
]:
y
=
fluid
.
layers
.
relu
(
x
)
y
=
paddle
.
nn
.
functional
.
relu
(
x
)
else
:
x_pow
=
paddle
.
pow
(
x
,
2
)
y
=
paddle
.
tanh
(
x_pow
)
...
...
@@ -163,7 +163,7 @@ def nested_if_else(x_v):
w
=
fluid
.
layers
.
fill_constant
([
feat_size
],
dtype
=
'float32'
,
value
=
10
)
if
y
.
numpy
()[
0
]
<
10
:
tmp
=
y
*
w
y
=
fluid
.
layers
.
relu
(
tmp
)
y
=
paddle
.
nn
.
functional
.
relu
(
tmp
)
if
paddle
.
mean
(
y
).
numpy
()[
0
]
<
batch_size
:
y
=
paddle
.
abs
(
y
)
else
:
...
...
@@ -273,7 +273,7 @@ class NetWithControlFlowIf(fluid.dygraph.Layer):
# Create new var, but is not used.
x
=
10
tmp
=
y
*
self
.
constant_vars
[
'w'
]
y
=
fluid
.
layers
.
relu
(
tmp
)
y
=
paddle
.
nn
.
functional
.
relu
(
tmp
)
# Nested `if/else`
if
y
.
numpy
()[
-
1
]
<
self
.
alpha
:
# Modify variable of class
...
...
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
浏览文件 @
676e4b35
...
...
@@ -35,7 +35,7 @@ class FusionGroupPassTest(PassTest):
tmp_0
=
self
.
feed_vars
[
0
]
*
self
.
feed_vars
[
1
]
tmp_1
=
layers
.
mul
(
tmp_0
,
self
.
feed_vars
[
2
])
# subgraph with 2 op nodes
tmp_2
=
layers
.
relu
(
tmp_0
+
tmp_1
)
tmp_2
=
paddle
.
nn
.
functional
.
relu
(
tmp_0
+
tmp_1
)
self
.
append_gradients
(
tmp_2
)
...
...
@@ -146,7 +146,7 @@ class FusionGroupPassTestCastAndFP16(FusionGroupPassTest):
tmp_3
=
layers
.
mul
(
tmp_0
,
self
.
feed_vars
[
2
])
# subgraph with 4 op nodes
tmp_3
=
layers
.
cast
(
tmp_2
,
dtype
=
"float16"
)
tmp_4
=
layers
.
relu
(
tmp_1
+
tmp_3
)
tmp_4
=
paddle
.
nn
.
functional
.
relu
(
tmp_1
+
tmp_3
)
tmp_5
=
layers
.
cast
(
tmp_4
,
dtype
=
dtype
)
tmp_3
=
layers
.
cast
(
tmp_2
,
dtype
=
dtype
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录