Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0ff5d8b0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
提交
0ff5d8b0
编写于
9月 25, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Port logical_ops to nn
上级
55467169
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
155 addition
and
58 deletion
+155
-58
python/paddle/fluid/layers/control_flow.py
python/paddle/fluid/layers/control_flow.py
+1
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+154
-53
python/paddle/fluid/layers/ops.py
python/paddle/fluid/layers/ops.py
+0
-4
未找到文件。
python/paddle/fluid/layers/control_flow.py
浏览文件 @
0ff5d8b0
...
...
@@ -21,7 +21,7 @@ from .. import core
from
..framework
import
Program
,
Variable
,
Operator
from
..layer_helper
import
LayerHelper
,
unique_name
from
..initializer
import
force_init_on_cpu
from
.
ops
import
logical_and
,
logical_not
,
logical_or
from
.
nn
import
logical_and
,
logical_not
,
logical_or
import
numpy
import
warnings
import
six
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
0ff5d8b0
...
...
@@ -133,6 +133,10 @@ __all__ = [
'elementwise_max'
,
'elementwise_min'
,
'elementwise_pow'
,
'logical_and'
,
'logical_or'
,
'logical_xor'
,
'logical_not'
,
]
...
...
@@ -6616,3 +6620,100 @@ for func in [
"act (basestring|None): Activation applied to the output."
,
"name (basestring|None): Name of the output."
])
def
_logical_op
(
op_name
,
x
,
y
,
name
=
None
,
out
=
None
,
binary_op
=
True
):
helper
=
LayerHelper
(
op_name
,
**
locals
())
assert
x
.
dtype
==
y
.
dtype
if
out
is
None
:
if
name
is
None
:
out
=
helper
.
create_tmp_variable
(
dtype
=
x
.
dtype
)
else
:
out
=
helper
.
create_variable
(
name
=
name
,
dtype
=
x
.
dtype
,
persistable
=
False
)
if
binary_op
:
helper
.
append_op
(
type
=
op_name
,
inputs
=
{
"X"
:
x
,
"Y"
:
y
},
outputs
=
{
"Out"
:
out
})
else
:
helper
.
append_op
(
type
=
op_name
,
inputs
=
{
"X"
:
x
},
outputs
=
{
"Out"
:
out
})
return
out
@
templatedoc
()
def
logical_and
(
x
,
y
,
name
=
None
,
out
=
None
):
"""
${comment}
Args:
x(${x_type}): ${x_comment}
y(${y_type}): ${y_comment}
out(Tensor): Output tensor of logical operation.
name(basestring|None): Name of the output.
Returns:
out(${out_type}): ${out_comment}
"""
return
_logical_op
(
op_name
=
"logical_and"
,
x
=
x
,
y
=
y
,
name
=
name
,
out
=
out
,
binary_op
=
True
)
@
templatedoc
()
def
logical_or
(
x
,
y
,
name
=
None
,
out
=
None
):
"""
${comment}
Args:
x(${x_type}): ${x_comment}
y(${y_type}): ${y_comment}
out(Tensor): Output tensor of logical operation.
name(basestring|None): Name of the output.
Returns:
out(${out_type}): ${out_comment}
"""
return
_logical_op
(
op_name
=
"logical_or"
,
x
=
x
,
y
=
y
,
name
=
name
,
out
=
out
,
binary_op
=
True
)
@
templatedoc
()
def
logical_xor
(
x
,
y
,
name
=
None
,
out
=
None
):
"""
${comment}
Args:
x(${x_type}): ${x_comment}
y(${y_type}): ${y_comment}
out(Tensor): Output tensor of logical operation.
name(basestring|None): Name of the output.
Returns:
out(${out_type}): ${out_comment}
"""
return
_logical_op
(
op_name
=
"logical_xor"
,
x
=
x
,
y
=
y
,
name
=
name
,
out
=
out
,
binary_op
=
True
)
@
templatedoc
()
def
logical_not
(
x
,
name
=
None
,
out
=
None
):
"""
${comment}
Args:
x(${x_type}): ${x_comment}
out(Tensor): Output tensor of logical operation.
name(basestring|None): Name of the output.
Returns:
out(${out_type}): ${out_comment}
"""
return
_logical_op
(
op_name
=
"logical_not"
,
x
=
x
,
y
=
None
,
name
=
name
,
out
=
out
,
binary_op
=
False
)
python/paddle/fluid/layers/ops.py
浏览文件 @
0ff5d8b0
...
...
@@ -41,10 +41,6 @@ __all__ = [
'sigmoid_cross_entropy_with_logits'
,
'clip'
,
'clip_by_norm'
,
'logical_and'
,
'logical_or'
,
'logical_xor'
,
'logical_not'
,
'uniform_random_batch_size_like'
,
'gaussian_random'
,
'sampling_id'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录