Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
6bac3e17
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
6bac3e17
编写于
8月 09, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"remove unused test net modified"
上级
df4fe671
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
13 deletion
+15
-13
paddle/operators/gaussian_random_op.cc
paddle/operators/gaussian_random_op.cc
+4
-3
paddle/operators/gaussian_random_op.cu
paddle/operators/gaussian_random_op.cu
+2
-3
python/paddle/v2/framework/tests/test_gaussian_random_op.py
python/paddle/v2/framework/tests/test_gaussian_random_op.py
+3
-1
python/paddle/v2/framework/tests/test_net.py
python/paddle/v2/framework/tests/test_net.py
+6
-6
未找到文件。
paddle/operators/gaussian_random_op.cc
浏览文件 @
6bac3e17
...
...
@@ -22,8 +22,8 @@ template <typename T>
class
GaussianRandomKernel
:
public
framework
::
OpKernel
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
T
mean
=
static_cast
<
T
>
(
context
.
op_
.
GetAttr
<
T
>
(
"mean"
)
);
T
std
=
static_cast
<
T
>
(
context
.
op_
.
GetAttr
<
T
>
(
"std"
)
);
float
mean
=
context
.
op_
.
GetAttr
<
float
>
(
"mean"
);
float
std
=
context
.
op_
.
GetAttr
<
float
>
(
"std"
);
auto
*
tensor
=
context
.
Output
<
framework
::
Tensor
>
(
0
);
T
*
data
=
tensor
->
mutable_data
<
T
>
(
context
.
GetPlace
());
...
...
@@ -35,7 +35,8 @@ class GaussianRandomKernel : public framework::OpKernel {
}
std
::
mt19937
g
(
seed
);
std
::
normal_distribution
<
T
>
distribution
(
mean
,
std
);
for
(
int
i
=
0
;
i
<
framework
::
product
(
tensor
->
dims
());
++
i
)
{
ssize_t
size
=
framework
::
product
(
tensor
->
dims
());
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
data
[
i
]
=
distribution
(
g
);
}
}
...
...
paddle/operators/gaussian_random_op.cu
浏览文件 @
6bac3e17
...
...
@@ -26,8 +26,8 @@ template <typename T>
class
GaussianRandomKernel
:
public
framework
::
OpKernel
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
T
mean
=
static_cast
<
T
>
(
context
.
op_
.
GetAttr
<
T
>
(
"mean"
)
);
T
std
=
static_cast
<
T
>
(
context
.
op_
.
GetAttr
<
T
>
(
"std"
)
);
float
mean
=
context
.
op_
.
GetAttr
<
float
>
(
"mean"
);
float
std
=
context
.
op_
.
GetAttr
<
float
>
(
"std"
);
auto
*
tensor
=
context
.
Output
<
framework
::
Tensor
>
(
0
);
T
*
data
=
tensor
->
mutable_data
<
T
>
(
context
.
GetPlace
());
...
...
@@ -40,7 +40,6 @@ class GaussianRandomKernel : public framework::OpKernel {
&
g
,
CURAND_RNG_PSEUDO_DEFAULT
));
PADDLE_ENFORCE
(
platform
::
dynload
::
curandSetPseudoRandomGeneratorSeed
(
g
,
seed
));
// auto g = const_cast<platform::GPUDeviceContext*>(ctx)->RandGenerator();
curandGenerateNormal
(
g
,
data
,
framework
::
product
(
tensor
->
dims
()),
mean
,
std
);
}
...
...
python/paddle/v2/framework/tests/test_gaussian_random_op.py
浏览文件 @
6bac3e17
...
...
@@ -14,13 +14,15 @@ class GaussianRandomTest(unittest.TestCase):
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
)
seed
=
10
)
op
.
infer_shape
(
scope
)
context
=
core
.
DeviceContext
.
create
(
place
)
op
.
run
(
scope
,
context
)
...
...
python/paddle/v2/framework/tests/test_net.py
浏览文件 @
6bac3e17
...
...
@@ -16,13 +16,13 @@ class TestNet(unittest.TestCase):
net
.
complete_add_op
(
True
)
expected
=
'''
Op(plain_net), inputs:(@EMPTY@, X, Y, w), outputs:(@TEMP@fc@0, Out, fc.out).
Op(add_two), inputs:(X, Y), outputs:(Out).
Op(plain_net), inputs:(@EMPTY@, X, w), outputs:(@TEMP@fc@0, fc.out).
Op(plain_net), inputs:(@EMPTY@, X, Y, w), outputs:(@TEMP@fc@0, Out, fc.out).
Op(add_two), inputs:(X, Y), outputs:(Out).
Op(plain_net), inputs:(@EMPTY@, X, w), outputs:(@TEMP@fc@0, fc.out).
Op(fc), inputs:(X, w, @EMPTY@), outputs:(fc.out, @TEMP@fc@0).
Op(mul), inputs:(X, w), outputs:(@TEMP@fc@0).
Op(sigmoid), inputs:(@TEMP@fc@0), outputs:(fc.out).
'''
Op(mul), inputs:(X, w), outputs:(@TEMP@fc@0).
Op(sigmoid), inputs:(@TEMP@fc@0), outputs:(fc.out).
'''
self
.
assertEqual
(
expected
,
"
\n
"
+
str
(
net
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录