Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1e676f68
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
提交
1e676f68
编写于
8月 01, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add mean op unit test in python
上级
bb7f3459
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
6 deletion
+32
-6
paddle/operators/mean_op.cu
paddle/operators/mean_op.cu
+3
-2
paddle/operators/mean_op.h
paddle/operators/mean_op.h
+2
-2
paddle/pybind/CMakeLists.txt
paddle/pybind/CMakeLists.txt
+9
-2
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+1
-0
python/paddle/v2/framework/tests/CMakeLists.txt
python/paddle/v2/framework/tests/CMakeLists.txt
+1
-0
python/paddle/v2/framework/tests/test_mean_op.py
python/paddle/v2/framework/tests/test_mean_op.py
+16
-0
未找到文件。
paddle/operators/mean_op.cu
浏览文件 @
1e676f68
#include "paddle/framework/op_registry.h"
#define EIGEN_USE_GPU
#include "paddle/operators/mean_op.h"
#include "paddle/operators/mean_op.h"
REGISTER_OP_GPU_KERNEL
(
mean
,
ops
::
Add
Kernel
<
ops
::
GPUPlace
,
float
>
);
REGISTER_OP_GPU_KERNEL
(
mean
,
ops
::
Mean
Kernel
<
ops
::
GPUPlace
,
float
>
);
paddle/operators/mean_op.h
浏览文件 @
1e676f68
...
@@ -26,8 +26,8 @@ public:
...
@@ -26,8 +26,8 @@ public:
auto
output
=
context
.
Output
(
0
)
->
GetMutable
<
Tensor
>
();
auto
output
=
context
.
Output
(
0
)
->
GetMutable
<
Tensor
>
();
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenScalar
<
T
>::
From
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenVector
<
T
>::
Flatten
(
input
).
mean
();
EigenVector
<
T
>::
Flatten
(
input
).
mean
();
}
}
};
};
...
...
paddle/pybind/CMakeLists.txt
浏览文件 @
1e676f68
cc_library
(
paddle_pybind SHARED SRCS pybind.cc DEPS pybind python
cc_library
(
paddle_pybind SHARED
add_op fc_op sgd_op cross_entropy_op recurrent_network_op
)
SRCS pybind.cc
DEPS pybind python
fc_op
sgd_op
add_op
mean_op
cross_entropy_op
recurrent_network_op
)
paddle/pybind/pybind.cc
浏览文件 @
1e676f68
...
@@ -33,6 +33,7 @@ USE_OP(onehot_cross_entropy);
...
@@ -33,6 +33,7 @@ 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
(
mul
);
USE_OP
(
mean
);
USE_OP
(
sigmoid
);
USE_OP
(
sigmoid
);
USE_OP
(
softmax
);
USE_OP
(
softmax
);
USE_OP
(
rowwise_add
);
USE_OP
(
rowwise_add
);
...
...
python/paddle/v2/framework/tests/CMakeLists.txt
浏览文件 @
1e676f68
...
@@ -10,6 +10,7 @@ add_python_test(test_framework
...
@@ -10,6 +10,7 @@ add_python_test(test_framework
test_sgd_op.py
test_sgd_op.py
test_cross_entropy_op.py
test_cross_entropy_op.py
test_mul_op.py
test_mul_op.py
test_mean_op.py
test_sigmoid_op.py
test_sigmoid_op.py
test_softmax_op.py
test_softmax_op.py
test_rowwise_add_op.py
test_rowwise_add_op.py
...
...
python/paddle/v2/framework/tests/test_mean_op.py
0 → 100644
浏览文件 @
1e676f68
import
unittest
from
op_test_util
import
OpTestMeta
import
numpy
as
np
class
TestMeanOp
(
unittest
.
TestCase
):
__metaclass__
=
OpTestMeta
def
setUp
(
self
):
self
.
type
=
"mean"
self
.
X
=
np
.
random
.
random
((
32
,
784
)).
astype
(
"float32"
)
self
.
Out
=
np
.
mean
(
self
.
X
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录