Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
e6366e34
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看板
提交
e6366e34
编写于
4月 11, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update with comments
上级
ba68ce1a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
22 deletion
+25
-22
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
+4
-4
paddle/gserver/layers/SequencePoolLayer.h
paddle/gserver/layers/SequencePoolLayer.h
+2
-2
paddle/gserver/tests/test_LayerGrad.cpp
paddle/gserver/tests/test_LayerGrad.cpp
+14
-10
paddle/parameter/Argument.cpp
paddle/parameter/Argument.cpp
+5
-6
未找到文件。
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
浏览文件 @
e6366e34
...
...
@@ -42,7 +42,7 @@ class SequenceLastInstanceLayer : public SequencePoolLayer {
protected:
MatrixPtr
tmpSrc_
;
MatrixPtr
tmpDest_
;
std
::
vector
<
int
>
ins
Id
_
;
std
::
vector
<
int
>
ins
tanceIds
_
;
public:
explicit
SequenceLastInstanceLayer
(
const
LayerConfig
&
config
)
...
...
@@ -82,10 +82,10 @@ void SequenceLastInstanceLayer::forward(PassType passType) {
AsyncGpuBlock
asyncGpuBlock
;
REGISTER_TIMER_INFO
(
"SequenceLastInstanceLayerForward"
,
getName
().
c_str
());
ins
Id
_
.
clear
();
ins
tanceIds
_
.
clear
();
for
(
size_t
seqId
=
0
;
seqId
<
newBatchSize_
;
++
seqId
)
{
int
insId
=
reversed_
?
starts
[
seqId
]
:
starts
[
seqId
+
1
]
-
1
;
ins
Id
_
.
push_back
(
insId
);
ins
tanceIds
_
.
push_back
(
insId
);
outputValue
->
subMatrix
(
seqId
,
1
,
tmpDest_
)
->
assign
(
*
(
inputValue
->
subMatrix
(
insId
,
1
,
tmpSrc_
)));
...
...
@@ -111,7 +111,7 @@ void SequenceLastInstanceLayer::backward(const UpdateCallback& callback) {
REGISTER_TIMER_INFO
(
"SequenceLastInstanceLayerBackward"
,
getName
().
c_str
());
for
(
size_t
seqId
=
0
;
seqId
<
newBatchSize_
;
++
seqId
)
{
inputGrad
->
subMatrix
(
ins
Id
_
[
seqId
],
1
,
tmpDest_
)
inputGrad
->
subMatrix
(
ins
tanceIds
_
[
seqId
],
1
,
tmpDest_
)
->
add
(
*
(
outputGrad
->
subMatrix
(
seqId
,
1
,
tmpSrc_
)));
}
}
...
...
paddle/gserver/layers/SequencePoolLayer.h
浏览文件 @
e6366e34
...
...
@@ -47,9 +47,9 @@ protected:
size_t
newBatchSize_
;
ICpuGpuVectorPtr
startPositions_
;
int
stride_
;
//
store the start position of each window
//
Store the start position of each window.
IVectorPtr
stridePositions_
;
// Whether the input sequence is reversed or not
// Whether the input sequence is reversed or not
.
bool
reversed_
=
false
;
public:
...
...
paddle/gserver/tests/test_LayerGrad.cpp
浏览文件 @
e6366e34
...
...
@@ -807,7 +807,7 @@ TEST(Layer, ExpandLayer) {
void
testDegradeLayer
(
bool
hasSubseq
,
string
layer_type
,
string
trans_type
,
int
stride
=
-
1
)
{
int
stride
)
{
TestConfig
config
;
config
.
layerConfig
.
set_type
(
layer_type
);
config
.
layerConfig
.
set_size
(
10
);
...
...
@@ -844,29 +844,33 @@ void testDegradeLayer(bool hasSubseq,
}
TEST
(
Layer
,
MaxLayer
)
{
testDegradeLayer
(
false
,
"max"
,
"non-seq"
);
// seq max to non-seq
testDegradeLayer
(
true
,
"max"
,
"non-seq"
);
// hasSubseq max to non-seq
testDegradeLayer
(
true
,
"max"
,
"seq"
);
// hasSubseq max to seq
testDegradeLayer
(
false
,
"max"
,
"non-seq"
,
-
1
);
// seq max to non-seq
testDegradeLayer
(
true
,
"max"
,
"non-seq"
,
-
1
);
// hasSubseq max to non-seq
testDegradeLayer
(
true
,
"max"
,
"seq"
,
-
1
);
// hasSubseq max to seq
}
TEST
(
Layer
,
SequenceLastInstanceLayer
)
{
testDegradeLayer
(
false
,
"seqlastins"
,
"non-seq"
);
// seq seqlastins to non-seq
"non-seq"
,
-
1
);
// seq seqlastins to non-seq
testDegradeLayer
(
false
,
"seqlastins"
,
"non-seq"
,
5
);
// seq seqlastins to a shorten seq, stride window = 5
testDegradeLayer
(
true
,
"seqlastins"
,
"non-seq"
);
// hasSubseq seqlastins to non-seq
testDegradeLayer
(
true
,
"seqlastins"
,
"seq"
);
// hasSubseq seqlastins to seq
"non-seq"
,
-
1
);
// hasSubseq seqlastins to non-seq
testDegradeLayer
(
true
,
"seqlastins"
,
"seq"
,
-
1
);
// hasSubseq seqlastins to seq
}
TEST
(
Layer
,
AverageLayer
)
{
testDegradeLayer
(
false
,
"average"
,
"non-seq"
);
// seq average to non-seq
testDegradeLayer
(
true
,
"average"
,
"non-seq"
);
// hasSubseq average to non-seq
testDegradeLayer
(
true
,
"average"
,
"seq"
);
// hasSubseq average to seq
testDegradeLayer
(
false
,
"average"
,
"non-seq"
,
-
1
);
// seq average to non-seq
testDegradeLayer
(
true
,
"average"
,
"non-seq"
,
-
1
);
// hasSubseq average to non-seq
testDegradeLayer
(
true
,
"average"
,
"seq"
,
-
1
);
// hasSubseq average to seq
}
TEST
(
Layer
,
SequenceConcatLayer
)
{
...
...
paddle/parameter/Argument.cpp
浏览文件 @
e6366e34
...
...
@@ -563,12 +563,11 @@ void Argument::poolSequenceWithStride(const Argument& input,
size_t
stride
,
IVectorPtr
*
stridePostions
,
bool
reversed
)
{
/*
* If input.sequenceStartPositions = [0, 9, 14, 17, 30] and stride = 5,
* then sequenceStartPositions = [0, 2, 3, 4, 7].
* If reversed = false, stridePostions = [0, 5, 9, 14, 17, 22, 27, 30];
* else reversed = true, stridePostions = [0, 4, 9, 14, 17, 20, 25, 30]
*/
// If input.sequenceStartPositions = [0, 9, 14, 17, 30] and stride = 5,
// then sequenceStartPositions = [0, 2, 3, 4, 7].
// If reversed = false, stridePostions = [0, 5, 9, 14, 17, 22, 27, 30];
// else reversed = true, stridePostions = [0, 4, 9, 14, 17, 20, 25, 30]
CHECK
(
input
.
sequenceStartPositions
);
CHECK_EQ
(
input
.
hasSubseq
(),
0UL
);
CHECK_GT
(
stride
,
0
)
<<
"stride must larger than 0"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录