Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6e80b84d
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看板
未验证
提交
6e80b84d
编写于
1月 06, 2023
作者:
W
Weilong Wu
提交者:
GitHub
1月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] polish several api (#49589)
上级
cac5f5a7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
15 deletion
+13
-15
python/paddle/nn/functional/activation.py
python/paddle/nn/functional/activation.py
+9
-11
python/paddle/nn/functional/common.py
python/paddle/nn/functional/common.py
+3
-2
python/paddle/nn/functional/pooling.py
python/paddle/nn/functional/pooling.py
+1
-2
未找到文件。
python/paddle/nn/functional/activation.py
浏览文件 @
6e80b84d
...
...
@@ -494,11 +494,6 @@ def prelu(x, weight, data_format="NCHW", name=None):
# [-1.25, 6. , 7. , -2. ],
# [ 6. , 7. , 8. , 9. ]]]]
"""
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'prelu'
)
check_variable_and_dtype
(
weight
,
'weight'
,
[
'float16'
,
'float32'
,
'float64'
],
'prelu'
)
assert
(
len
(
weight
.
shape
)
==
1
),
"The dim count of weight shape should be 1 in prelu()."
...
...
@@ -541,6 +536,12 @@ def prelu(x, weight, data_format="NCHW", name=None):
if
in_dygraph_mode
():
return
_C_ops
.
prelu
(
x
,
weight
,
data_format
,
mode
)
else
:
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'prelu'
)
check_variable_and_dtype
(
weight
,
'weight'
,
[
'float16'
,
'float32'
,
'float64'
],
'prelu'
)
helper
=
LayerHelper
(
'prelu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
helper
.
append_op
(
...
...
@@ -622,12 +623,6 @@ def rrelu(x, lower=1.0 / 8.0, upper=1.0 / 3.0, training=True, name=None):
# [-1.3766339 6. 7. -2.3465784 ]
# [ 6. 7. 8. 9. ]]]]
"""
if
not
in_dynamic_mode
():
check_variable_and_dtype
(
x
,
'X'
,
[
'float16'
,
'float32'
,
'float64'
],
'rrelu'
)
if
not
isinstance
(
lower
,
float
)
or
not
isinstance
(
upper
,
float
):
raise
TypeError
(
"The lower and upper values must be float type. Received: lower {}, upper {}."
.
format
(
...
...
@@ -664,6 +659,9 @@ def rrelu(x, lower=1.0 / 8.0, upper=1.0 / 3.0, training=True, name=None):
)
return
out
else
:
check_variable_and_dtype
(
x
,
'X'
,
[
'float16'
,
'float32'
,
'float64'
],
'rrelu'
)
helper
=
LayerHelper
(
'rrelu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
noise
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
...
python/paddle/nn/functional/common.py
浏览文件 @
6e80b84d
...
...
@@ -422,9 +422,7 @@ def interpolate(
return
paddle
.
nn
.
functional
.
adaptive_avg_pool2d
(
x
,
size
)
elif
len
(
x
.
shape
)
==
5
:
return
paddle
.
nn
.
functional
.
adaptive_avg_pool3d
(
x
,
size
)
helper
=
LayerHelper
(
'{}_interp_v2'
.
format
(
resample_type
),
**
locals
())
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
if
len
(
x
.
shape
)
==
3
and
data_format
not
in
[
'NCW'
,
'NWC'
]:
raise
ValueError
(
"Got wrong value for param `data_format`: "
...
...
@@ -678,6 +676,9 @@ def interpolate(
else
:
out
=
_legacy_C_ops
.
bicubic_interp_v2
(
x
,
*
dy_attr
)
return
out
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
)
helper
.
append_op
(
type
=
'{}_interp_v2'
.
format
(
resample_type
),
...
...
python/paddle/nn/functional/pooling.py
浏览文件 @
6e80b84d
...
...
@@ -597,8 +597,6 @@ def max_pool1d(
"""
"""NCL to NCHW"""
data_format
=
"NCHW"
if
not
in_dynamic_mode
():
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
],
'max_pool1d'
)
_check_input
(
x
,
3
)
x
=
unsqueeze
(
x
,
[
2
])
kernel_size
=
[
1
]
+
utils
.
convert_to_list
(
kernel_size
,
1
,
'pool_size'
)
...
...
@@ -641,6 +639,7 @@ def max_pool1d(
return
squeeze
(
pool_out
,
[
2
])
else
:
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
],
'max_pool1d'
)
op_type
=
'max_pool2d_with_index'
if
return_mask
else
"pool2d"
helper
=
LayerHelper
(
op_type
,
**
locals
())
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录