Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SummerGao.
Paddle
提交
4223ff8c
P
Paddle
项目概览
SummerGao.
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4223ff8c
编写于
9月 11, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct the key name of "mul" op in FCOp, and add some annotations for debug.
上级
70e60d73
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
9 deletion
+8
-9
paddle/operators/fc_op.cc
paddle/operators/fc_op.cc
+3
-1
python/paddle/v2/framework/tests/op_test.py
python/paddle/v2/framework/tests/op_test.py
+4
-4
python/paddle/v2/framework/tests/test_fc_op.py
python/paddle/v2/framework/tests/test_fc_op.py
+1
-4
未找到文件。
paddle/operators/fc_op.cc
浏览文件 @
4223ff8c
...
@@ -37,7 +37,7 @@ class FCOp : public NetOp {
...
@@ -37,7 +37,7 @@ class FCOp : public NetOp {
// mul_out = X[0] * W[0] + ... + X[n-1] * W[n-1]
// mul_out = X[0] * W[0] + ... + X[n-1] * W[n-1]
AppendOp
(
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
"mul"
,
{{
"X"
,
{
x
[
0
]}},
{
"
W
"
,
{
w
[
0
]}}},
framework
::
OpRegistry
::
CreateOp
(
"mul"
,
{{
"X"
,
{
x
[
0
]}},
{
"
Y
"
,
{
w
[
0
]}}},
{{
"Out"
,
{
Output
(
"mul_out"
)}}},
{}));
{{
"Out"
,
{
Output
(
"mul_out"
)}}},
{}));
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
...
@@ -68,6 +68,8 @@ class FCOp : public NetOp {
...
@@ -68,6 +68,8 @@ class FCOp : public NetOp {
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
AppendOp
(
framework
::
OpRegistry
::
CreateOp
(
activation
,
{{
"X"
,
{
Output
(
add_out
)}}},
{{
"Y"
,
{
Output
(
"Y"
)}}},
{}));
activation
,
{{
"X"
,
{
Output
(
add_out
)}}},
{{
"Y"
,
{
Output
(
"Y"
)}}},
{}));
CompleteAddOp
(
false
);
CompleteAddOp
(
false
);
std
::
cout
<<
DebugString
()
<<
std
::
endl
;
}
}
};
};
...
...
python/paddle/v2/framework/tests/op_test.py
浏览文件 @
4223ff8c
...
@@ -36,8 +36,8 @@ def create_op(scope, op_type, inputs, outputs, attrs=None):
...
@@ -36,8 +36,8 @@ def create_op(scope, op_type, inputs, outputs, attrs=None):
var
=
scope
.
new_var
(
out_name
)
var
=
scope
.
new_var
(
out_name
)
kwargs
[
out_name
].
append
(
out_name
)
kwargs
[
out_name
].
append
(
out_name
)
for
attr_name
in
Operator
.
get_op_attr_names
(
op_type
):
#
for attr_name in Operator.get_op_attr_names(op_type):
kwargs
[
attr_name
]
=
attrs
[
attr_name
]
#
kwargs[attr_name] = attrs[attr_name]
return
Operator
(
op_type
,
**
kwargs
)
return
Operator
(
op_type
,
**
kwargs
)
...
@@ -186,14 +186,14 @@ class OpTest(unittest.TestCase):
...
@@ -186,14 +186,14 @@ class OpTest(unittest.TestCase):
self
.
assertTrue
(
self
.
assertTrue
(
np
.
allclose
(
np
.
allclose
(
actual
,
expect
,
atol
=
1e-05
),
actual
,
expect
,
atol
=
1e-05
),
"output name: "
+
out_name
+
"has diff"
)
"output name: "
+
out_name
+
"
has diff"
)
else
:
else
:
actual
=
np
.
array
(
self
.
scope
.
find_var
(
out_name
).
get_tensor
())
actual
=
np
.
array
(
self
.
scope
.
find_var
(
out_name
).
get_tensor
())
expect
=
self
.
outputs
[
out_name
]
expect
=
self
.
outputs
[
out_name
]
self
.
assertTrue
(
self
.
assertTrue
(
np
.
allclose
(
np
.
allclose
(
actual
,
expect
,
atol
=
1e-05
),
actual
,
expect
,
atol
=
1e-05
),
"output name: "
+
out_name
+
"has diff"
)
"output name: "
+
out_name
+
"
has diff"
)
def
check_output
(
self
):
def
check_output
(
self
):
places
=
[
core
.
CPUPlace
()]
places
=
[
core
.
CPUPlace
()]
...
...
python/paddle/v2/framework/tests/test_fc_op.py
浏览文件 @
4223ff8c
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
import
paddle.v2.framework.core
as
core
from
paddle.v2.framework.op
import
Operator
class
TestFCOp
(
OpTest
):
class
TestFCOp
(
OpTest
):
...
@@ -37,8 +35,7 @@ class TestFCOp(OpTest):
...
@@ -37,8 +35,7 @@ class TestFCOp(OpTest):
}
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
(
core
.
CPUPlace
())
self
.
check_output
()
self
.
check_output
(
core
.
GPUPlace
(
0
))
#def test_check_grad(self):
#def test_check_grad(self):
# self.check_grad(["X0", "X1", "W0", "W1", "b"], "Y")
# self.check_grad(["X0", "X1", "W0", "W1", "b"], "Y")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录