Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
52d2ebda
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52d2ebda
编写于
8月 08, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"test gaussian random in python side"
上级
e2c08d28
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
37 addition
and
29 deletion
+37
-29
paddle/framework/CMakeLists.txt
paddle/framework/CMakeLists.txt
+1
-0
paddle/framework/pybind.cc
paddle/framework/pybind.cc
+1
-0
python/paddle/v2/framework/tests/CMakeLists.txt
python/paddle/v2/framework/tests/CMakeLists.txt
+2
-0
python/paddle/v2/framework/tests/test_gaussian_random_op.py
python/paddle/v2/framework/tests/test_gaussian_random_op.py
+33
-0
python/paddle/v2/framework/tests/test_random_op.py
python/paddle/v2/framework/tests/test_random_op.py
+0
-29
未找到文件。
paddle/framework/CMakeLists.txt
浏览文件 @
52d2ebda
...
...
@@ -43,4 +43,5 @@ cc_library(paddle_pybind SHARED
add_op
mean_op
cross_entropy_op
gaussian_random_op
recurrent_op
)
paddle/framework/pybind.cc
浏览文件 @
52d2ebda
...
...
@@ -41,6 +41,7 @@ USE_OP(sigmoid);
USE_OP
(
softmax
);
USE_OP
(
rowwise_add
);
USE_OP_WITHOUT_KERNEL
(
recurrent_op
);
USE_OP
(
gaussian_random
);
namespace
paddle
{
namespace
framework
{
template
<
typename
ClassType
>
...
...
python/paddle/v2/framework/tests/CMakeLists.txt
浏览文件 @
52d2ebda
...
...
@@ -21,3 +21,5 @@ py_test(test_rowwise_add_op SRCS test_rowwise_add_op.py)
py_test
(
test_default_scope_funcs SRCS test_default_scope_funcs.py
)
py_test
(
test_op_creation_methods SRCS test_op_creation_methods.py
)
py_test
(
test_gaussian_random_op SRCS test_gaussian_random_op.py
)
python/paddle/v2/framework/tests/test_gaussian_random_op.py
0 → 100644
浏览文件 @
52d2ebda
import
unittest
import
paddle.v2.framework.core
as
core
import
paddle.v2.framework.op
as
Operator
import
numpy
class
GaussianRandomTest
(
unittest
.
TestCase
):
def
test_cpu
(
self
):
self
.
test_gaussian_random
(
place
=
core
.
CPUPlace
())
def
test_gpu
(
self
):
self
.
test_gaussian_random
(
place
=
core
.
GPUPlace
(
0
))
def
test_gaussian_random
(
self
,
place
):
scope
=
core
.
Scope
()
scope
.
new_var
(
"Out"
).
get_tensor
()
op
=
Operator
(
"gaussian_random"
,
Out
=
"Out"
,
dims
=
[
1000
,
784
],
mean
=
.
0
,
std
=
1.
,
seed
=
0
)
op
.
infer_shape
(
scope
)
context
=
core
.
DeviceContext
.
create
(
place
)
op
.
run
(
scope
,
context
)
tensor
=
numpy
.
array
(
scope
.
find_var
(
"Out"
).
get_tensor
())
self
.
assertAlmostEqual
(
numpy
.
mean
(
tensor
),
.
0
,
places
=
3
)
self
.
assertAlmostEqual
(
numpy
.
std
(
tensor
),
1.
,
places
=
3
)
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/framework/tests/test_random_op.py
已删除
100644 → 0
浏览文件 @
e2c08d28
import
unittest
import
paddle.v2.framework.create_op_creation_methods
as
creation
import
paddle.v2.framework.core
as
core
from
op_test_util
import
OpTestMeta
import
numpy
class
TestRandomOp
(
unittest
.
TestCase
):
def
test_random
(
self
):
scope
=
core
.
Scope
(
None
)
# Out = scope.create_var("Out")
op
=
creation
.
op_creations
.
gaussian_random
(
shape
=
[
1000
,
1000
],
mean
=
5.0
,
std
=
1.0
,
Out
=
"Out"
)
for
out
in
op
.
outputs
():
if
scope
.
get_var
(
out
)
is
None
:
scope
.
create_var
(
out
).
get_tensor
()
tensor
=
scope
.
get_var
(
"Out"
).
get_tensor
()
op
.
infer_shape
(
scope
)
self
.
assertEqual
([
1000
,
1000
],
tensor
.
shape
())
ctx
=
core
.
DeviceContext
.
cpu_context
()
op
.
run
(
scope
,
ctx
)
tensor_array
=
numpy
.
array
(
tensor
)
self
.
assertAlmostEqual
(
numpy
.
mean
(
tensor_array
),
5.0
,
places
=
3
)
self
.
assertAlmostEqual
(
numpy
.
std
(
tensor_array
),
1.0
,
places
=
3
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录