Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
dae249b1
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dae249b1
编写于
9月 15, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete USE_OP statements and add more ENFORCE statements to check the inputs and outputs in FCOp.
上级
6ce4bf36
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
8 deletion
+19
-8
paddle/operators/fc_op.cc
paddle/operators/fc_op.cc
+17
-6
paddle/operators/identity_op.cc
paddle/operators/identity_op.cc
+2
-2
未找到文件。
paddle/operators/fc_op.cc
浏览文件 @
dae249b1
...
...
@@ -24,6 +24,15 @@ class FCOp : public NetOp {
const
framework
::
VariableNameMap
&
outputs
,
const
framework
::
AttributeMap
&
attrs
)
:
NetOp
(
type
,
inputs
,
outputs
,
attrs
)
{
PADDLE_ENFORCE
(
!
Inputs
(
"X"
).
empty
(),
"Inputs(X) of FCOp should not be null."
);
PADDLE_ENFORCE
(
!
Inputs
(
"W"
).
empty
(),
"Inputs(W) of FCOp should not be null."
);
PADDLE_ENFORCE
(
!
Outputs
(
"MulOut"
).
empty
(),
"Outputs(MulOut) of FCOp should not be null."
);
PADDLE_ENFORCE_NE
(
Output
(
"Out"
),
framework
::
kEmptyVarName
,
"Output(Out) of FCOp should not be null."
);
auto
x
=
Inputs
(
"X"
);
auto
w
=
Inputs
(
"W"
);
auto
mul_out
=
Outputs
(
"MulOut"
);
...
...
@@ -68,6 +77,10 @@ class FCOp : public NetOp {
// sum_out = X[0] * W[0] + ... + X[n-1] * W[n-1]
auto
sum_out
=
mul_out
[
0
];
if
(
n
>
1
)
{
PADDLE_ENFORCE_NE
(
Output
(
"SumOut"
),
framework
::
kEmptyVarName
,
"Output(SumOut) of FCOp should not be null when the "
"size of Inputs(X) > 1."
);
sum_out
=
Output
(
"SumOut"
);
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
"sum"
,
{{
"X"
,
{
mul_out
}}},
{{
"Out"
,
{
sum_out
}}},
{}));
...
...
@@ -81,6 +94,10 @@ class FCOp : public NetOp {
auto
b
=
Input
(
"B"
);
auto
add_out
=
sum_out
;
if
(
b
!=
framework
::
kEmptyVarName
)
{
PADDLE_ENFORCE_NE
(
Output
(
"AddOut"
),
framework
::
kEmptyVarName
,
"Output(AddOut) of FCOp should not be null when Input(B) is set."
);
add_out
=
Output
(
"AddOut"
);
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
"rowwise_add"
,
{{
"X"
,
{
sum_out
}},
{
"b"
,
{
Input
(
"B"
)}}},
...
...
@@ -176,11 +193,5 @@ Activation type can be set to `identity` (default), `sigmoid` or `softmax`.
}
// namespace operators
}
// namespace paddle
USE_OP
(
mul
);
USE_OP
(
rowwise_add
);
USE_NO_KERNEL_OP
(
identity
);
USE_OP
(
sigmoid
);
USE_OP
(
softmax
);
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_WITHOUT_GRADIENT
(
fc
,
ops
::
FCOp
,
ops
::
FCOpMaker
);
paddle/operators/identity_op.cc
浏览文件 @
dae249b1
...
...
@@ -44,8 +44,8 @@ class IdentityOp : public NetOp {
:
NetOp
(
type
,
inputs
,
outputs
,
attrs
)
{
PADDLE_ENFORCE_NE
(
Input
(
"X"
),
framework
::
kEmptyVarName
,
"Input(X) of IdentityOp should not be null."
);
PADDLE_ENFORCE_NE
(
Output
(
"
Out
"
),
framework
::
kEmptyVarName
,
"Output(
Out
) of IdentityOp should not be null."
);
PADDLE_ENFORCE_NE
(
Output
(
"
Y
"
),
framework
::
kEmptyVarName
,
"Output(
Y
) of IdentityOp should not be null."
);
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
"scale"
,
{{
"X"
,
{
Input
(
"X"
)}}},
{{
"Out"
,
{
Output
(
"Y"
)}}},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录