Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6246be29
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6246be29
编写于
10月 21, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean gradient data
上级
4d112b7d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
13 addition
and
4 deletion
+13
-4
paddle/operators/sequence_project_op.cc
paddle/operators/sequence_project_op.cc
+2
-0
paddle/operators/sequence_project_op.h
paddle/operators/sequence_project_op.h
+8
-1
python/paddle/v2/framework/tests/test_seq_project.py
python/paddle/v2/framework/tests/test_seq_project.py
+3
-3
未找到文件。
paddle/operators/sequence_project_op.cc
浏览文件 @
6246be29
...
...
@@ -71,6 +71,8 @@ class SequenceProjectGradOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
"Gradient of Out should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"The input X should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)),
"Gradient of input(X@GRAD) should not be null."
);
if
(
ctx
->
Attrs
().
Get
<
bool
>
(
"padding_trainable"
))
{
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"PaddingData"
)),
...
...
paddle/operators/sequence_project_op.h
浏览文件 @
6246be29
...
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include "paddle/framework/eigen.h"
#include "paddle/framework/op_registry.h"
#include "paddle/operators/math/im2col.h"
#include "paddle/operators/math/math_function.h"
#include "paddle/operators/strided_memcpy.h"
namespace
paddle
{
...
...
@@ -177,6 +178,10 @@ class SequenceProjectGradKernel : public framework::OpKernel<T> {
auto
*
in_g
=
context
.
Output
<
LoDTensor
>
(
framework
::
GradVarName
(
"X"
));
auto
*
in
=
context
.
Input
<
LoDTensor
>
(
"X"
);
in_g
->
mutable_data
<
T
>
(
context
.
GetPlace
());
if
(
in_g
)
{
math
::
SetConstant
<
Place
,
T
>
functor
;
functor
(
context
.
device_context
(),
in_g
,
0
);
}
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
int
context_start
=
context
.
Attr
<
int
>
(
"context_start"
);
...
...
@@ -204,6 +209,8 @@ class SequenceProjectGradKernel : public framework::OpKernel<T> {
padding_width
=
padding_data_g
->
dims
()[
1
];
PADDLE_ENFORCE
(
padding_width
==
input_width
,
"Input size and pooling size should be consistent."
);
math
::
SetConstant
<
Place
,
T
>
functor
;
functor
(
context
.
device_context
(),
padding_data_g
,
0
);
}
int
up_pad
=
std
::
max
(
0
,
-
context_start
);
...
...
@@ -282,7 +289,7 @@ class SequenceProjectGradKernel : public framework::OpKernel<T> {
}
}
if
(
in
&&
input_row_begin
<
input_row_end
)
{
if
(
in
_g
&&
input_row_begin
<
input_row_end
)
{
Tensor
in_t
=
in_g
->
Slice
(
input_row_begin
,
input_row_end
);
std
::
vector
<
int64_t
>
output_shape
(
...
...
python/paddle/v2/framework/tests/test_seq_project.py
浏览文件 @
6246be29
...
...
@@ -87,9 +87,9 @@ class TestSeqProject(OpTest):
def
test_check_output
(
self
):
self
.
check_output
()
#
def test_check_grad(self):
#
self.check_grad(
#
set(['X', 'PaddingData']), 'Out', max_relative_error=0.05)
def
test_check_grad
(
self
):
self
.
check_grad
(
set
([
'X'
,
'PaddingData'
]),
'Out'
,
max_relative_error
=
0.05
)
# def test_check_grad_no_filter(self):
# self.check_grad(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录