Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
06acd6d0
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
06acd6d0
编写于
7月 21, 2017
作者:
Q
qijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add unittest for some basic OpKernels
上级
ba790509
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
96 addition
and
5 deletion
+96
-5
paddle/operators/sigmoid_op.cc
paddle/operators/sigmoid_op.cc
+1
-1
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+4
-0
python/paddle/v2/framework/tests/CMakeLists.txt
python/paddle/v2/framework/tests/CMakeLists.txt
+14
-3
python/paddle/v2/framework/tests/op_test_util.py
python/paddle/v2/framework/tests/op_test_util.py
+4
-1
python/paddle/v2/framework/tests/test_mul_op.py
python/paddle/v2/framework/tests/test_mul_op.py
+17
-0
python/paddle/v2/framework/tests/test_rowwise_add_op.py
python/paddle/v2/framework/tests/test_rowwise_add_op.py
+17
-0
python/paddle/v2/framework/tests/test_sigmoid_op.py
python/paddle/v2/framework/tests/test_sigmoid_op.py
+16
-0
python/paddle/v2/framework/tests/test_softmax_op.py
python/paddle/v2/framework/tests/test_softmax_op.py
+23
-0
未找到文件。
paddle/operators/sigmoid_op.cc
浏览文件 @
06acd6d0
...
@@ -34,7 +34,7 @@ public:
...
@@ -34,7 +34,7 @@ public:
framework
::
OpAttrChecker
*
op_checker
)
framework
::
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"sigmoid input"
);
AddInput
(
"X"
,
"sigmoid input"
);
Add
In
put
(
"Y"
,
"sigmoid output"
);
Add
Out
put
(
"Y"
,
"sigmoid output"
);
AddComment
(
"Sigmoid function"
);
AddComment
(
"Sigmoid function"
);
}
}
};
};
...
...
paddle/pybind/pybind.cc
浏览文件 @
06acd6d0
...
@@ -30,6 +30,10 @@ USE_OP(add_two);
...
@@ -30,6 +30,10 @@ USE_OP(add_two);
USE_OP
(
onehot_cross_entropy
);
USE_OP
(
onehot_cross_entropy
);
USE_OP_WITHOUT_KERNEL
(
fc
);
USE_OP_WITHOUT_KERNEL
(
fc
);
USE_OP
(
sgd
);
USE_OP
(
sgd
);
USE_OP
(
mul
);
USE_OP
(
sigmoid
);
USE_OP
(
softmax
);
USE_OP
(
rowwise_add
);
PYBIND11_PLUGIN
(
core
)
{
PYBIND11_PLUGIN
(
core
)
{
py
::
module
m
(
"core"
,
"C++ core of Paddle Paddle"
);
py
::
module
m
(
"core"
,
"C++ core of Paddle Paddle"
);
...
...
python/paddle/v2/framework/tests/CMakeLists.txt
浏览文件 @
06acd6d0
add_python_test
(
test_framework test_protobuf.py test_scope.py
add_python_test
(
test_framework
test_default_scope_funcs.py test_op_creation_methods.py
test_protobuf.py
test_tensor.py test_fc_op.py test_add_two_op.py test_sgd_op.py test_cross_entropy_op.py
)
test_scope.py
test_default_scope_funcs.py
test_op_creation_methods.py
test_tensor.py
test_fc_op.py
test_add_two_op.py
test_sgd_op.py
test_cross_entropy_op.py
test_mul_op.py
test_sigmoid_op.py
test_softmax_op.py
test_rowwise_add_op.py
)
python/paddle/v2/framework/tests/op_test_util.py
浏览文件 @
06acd6d0
...
@@ -56,7 +56,10 @@ class OpTestMeta(type):
...
@@ -56,7 +56,10 @@ class OpTestMeta(type):
for
out_name
in
func
.
all_output_args
:
for
out_name
in
func
.
all_output_args
:
actual
=
numpy
.
array
(
scope
.
get_var
(
out_name
).
get_tensor
())
actual
=
numpy
.
array
(
scope
.
get_var
(
out_name
).
get_tensor
())
expect
=
getattr
(
self
,
out_name
)
expect
=
getattr
(
self
,
out_name
)
numpy
.
testing
.
assert_almost_equal
(
actual
,
expect
)
# TODO(qijun) The default decimal is 7, but numpy.dot and eigen.mul
# has some diff, and could not pass unittest. So I set decimal 3 here.
# And I will check this in future.
numpy
.
testing
.
assert_almost_equal
(
actual
,
expect
,
decimal
=
3
)
obj
.
test_all
=
test_all
obj
.
test_all
=
test_all
return
obj
return
obj
python/paddle/v2/framework/tests/test_mul_op.py
0 → 100644
浏览文件 @
06acd6d0
import
unittest
from
op_test_util
import
OpTestMeta
import
numpy
as
np
class
TestMulOp
(
unittest
.
TestCase
):
__metaclass__
=
OpTestMeta
def
setUp
(
self
):
self
.
type
=
"mul"
self
.
X
=
np
.
random
.
random
((
32
,
784
)).
astype
(
"float32"
)
self
.
Y
=
np
.
random
.
random
((
784
,
100
)).
astype
(
"float32"
)
self
.
Out
=
np
.
dot
(
self
.
X
,
self
.
Y
)
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/framework/tests/test_rowwise_add_op.py
0 → 100644
浏览文件 @
06acd6d0
import
unittest
from
op_test_util
import
OpTestMeta
import
numpy
as
np
class
TestRowwiseAddOp
(
unittest
.
TestCase
):
__metaclass__
=
OpTestMeta
def
setUp
(
self
):
self
.
type
=
"rowwise_add"
self
.
X
=
np
.
random
.
random
((
32
,
784
)).
astype
(
"float32"
)
self
.
b
=
np
.
random
.
random
(
784
).
astype
(
"float32"
)
self
.
Out
=
np
.
add
(
self
.
X
,
self
.
b
)
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/framework/tests/test_sigmoid_op.py
0 → 100644
浏览文件 @
06acd6d0
import
unittest
from
op_test_util
import
OpTestMeta
import
numpy
as
np
class
TestSigmoidOp
(
unittest
.
TestCase
):
__metaclass__
=
OpTestMeta
def
setUp
(
self
):
self
.
type
=
"sigmoid"
self
.
X
=
np
.
random
.
random
((
32
,
100
)).
astype
(
"float32"
)
self
.
Y
=
1
/
(
1
+
np
.
exp
(
-
self
.
X
))
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/framework/tests/test_softmax_op.py
0 → 100644
浏览文件 @
06acd6d0
import
unittest
from
op_test_util
import
OpTestMeta
import
numpy
as
np
def
stable_softmax
(
x
):
"""Compute the softmax of vector x in a numerically stable way."""
shiftx
=
x
-
np
.
max
(
x
)
exps
=
np
.
exp
(
shiftx
)
return
exps
/
np
.
sum
(
exps
)
class
TestSoftmaxOp
(
unittest
.
TestCase
):
__metaclass__
=
OpTestMeta
def
setUp
(
self
):
self
.
type
=
"softmax"
self
.
X
=
np
.
random
.
random
((
32
,
100
)).
astype
(
"float32"
)
self
.
Y
=
np
.
apply_along_axis
(
stable_softmax
,
1
,
self
.
X
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录