Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
96bc3352
P
Paddle
项目概览
机器未来
/
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看板
提交
96bc3352
编写于
12月 28, 2017
作者:
Y
Yang Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update
上级
c7322793
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
7 addition
and
5 deletion
+7
-5
paddle/framework/variable.h
paddle/framework/variable.h
+0
-1
paddle/operators/sum_op.h
paddle/operators/sum_op.h
+4
-2
python/paddle/v2/fluid/tests/test_dynrnn_gradient_check.py
python/paddle/v2/fluid/tests/test_dynrnn_gradient_check.py
+3
-2
未找到文件。
paddle/framework/variable.h
浏览文件 @
96bc3352
...
@@ -35,7 +35,6 @@ class Variable {
...
@@ -35,7 +35,6 @@ class Variable {
template
<
typename
T
>
template
<
typename
T
>
T
*
GetMutable
()
{
T
*
GetMutable
()
{
if
(
!
IsType
<
T
>
())
{
if
(
!
IsType
<
T
>
())
{
VLOG
(
10
)
<<
"Resetting "
<<
*
this
->
name_
;
holder_
.
reset
(
new
PlaceholderImpl
<
T
>
(
new
T
()));
holder_
.
reset
(
new
PlaceholderImpl
<
T
>
(
new
T
()));
}
}
return
static_cast
<
T
*>
(
holder_
->
Ptr
());
return
static_cast
<
T
*>
(
holder_
->
Ptr
());
...
...
paddle/operators/sum_op.h
浏览文件 @
96bc3352
...
@@ -37,10 +37,12 @@ class SumKernel : public framework::OpKernel<T> {
...
@@ -37,10 +37,12 @@ class SumKernel : public framework::OpKernel<T> {
bool
in_place
=
out_var
==
in_vars
[
0
];
bool
in_place
=
out_var
==
in_vars
[
0
];
if
(
out_var
->
IsType
<
framework
::
LoDTensor
>
())
{
if
(
out_var
->
IsType
<
framework
::
LoDTensor
>
())
{
auto
*
out
=
context
.
Output
<
Tensor
>
(
"Out"
);
auto
*
out
=
context
.
Output
<
LoDTensor
>
(
"Out"
);
auto
result
=
EigenVector
<
T
>::
Flatten
(
*
out
);
if
(
!
in_place
)
{
if
(
!
in_place
)
{
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
}
auto
result
=
EigenVector
<
T
>::
Flatten
(
*
out
);
if
(
!
in_place
)
{
math
::
SetConstant
<
DeviceContext
,
T
>
constant_functor
;
math
::
SetConstant
<
DeviceContext
,
T
>
constant_functor
;
constant_functor
(
context
.
template
device_context
<
DeviceContext
>(),
out
,
constant_functor
(
context
.
template
device_context
<
DeviceContext
>(),
out
,
0.0
);
0.0
);
...
...
python/paddle/v2/fluid/tests/test_dynrnn_gradient_check.py
浏览文件 @
96bc3352
...
@@ -242,7 +242,7 @@ class TestSimpleMul(unittest.TestCase):
...
@@ -242,7 +242,7 @@ class TestSimpleMul(unittest.TestCase):
out
=
rnn
()
out
=
rnn
()
out
=
fluid
.
layers
.
sequence_pool
(
out
,
pool_type
=
'last'
)
out
=
fluid
.
layers
.
sequence_pool
(
out
,
pool_type
=
'last'
)
loss
=
fluid
.
layers
.
mean
(
x
=
out
)
loss
=
fluid
.
layers
.
mean
(
x
=
out
)
fluid
.
backward
.
append_backward
_ops
(
loss
)
fluid
.
backward
.
append_backward
(
loss
)
cpu
=
fluid
.
CPUPlace
()
cpu
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
cpu
)
exe
=
fluid
.
Executor
(
cpu
)
...
@@ -317,7 +317,7 @@ class TestSimpleMulWithMemory(unittest.TestCase):
...
@@ -317,7 +317,7 @@ class TestSimpleMulWithMemory(unittest.TestCase):
out
=
rnn
()
out
=
rnn
()
last
=
fluid
.
layers
.
sequence_pool
(
input
=
out
,
pool_type
=
'last'
)
last
=
fluid
.
layers
.
sequence_pool
(
input
=
out
,
pool_type
=
'last'
)
loss
=
fluid
.
layers
.
mean
(
x
=
last
)
loss
=
fluid
.
layers
.
mean
(
x
=
last
)
fluid
.
backward
.
append_backward
_ops
(
loss
)
fluid
.
backward
.
append_backward
(
loss
)
cpu
=
fluid
.
CPUPlace
()
cpu
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
cpu
)
exe
=
fluid
.
Executor
(
cpu
)
...
@@ -330,6 +330,7 @@ class TestSimpleMulWithMemory(unittest.TestCase):
...
@@ -330,6 +330,7 @@ class TestSimpleMulWithMemory(unittest.TestCase):
],
],
return_numpy
=
False
))
return_numpy
=
False
))
last_by_py
,
=
py_rnn
.
exe
().
values
()
last_by_py
,
=
py_rnn
.
exe
().
values
()
print
w_g
[
0
]
self
.
assertTrue
(
numpy
.
allclose
(
last_np
,
last_by_py
))
self
.
assertTrue
(
numpy
.
allclose
(
last_np
,
last_by_py
))
w_g_num
=
py_rnn
.
get_numeric_gradient_of_param
(
self
.
PARAM_NAME
)
w_g_num
=
py_rnn
.
get_numeric_gradient_of_param
(
self
.
PARAM_NAME
)
# print w_g_num[0], w_g[0]
# print w_g_num[0], w_g[0]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录