Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
36f0aa73
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看板
提交
36f0aa73
编写于
8月 31, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code style to pass CI.
上级
3d1b8719
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
7 deletion
+10
-7
paddle/gserver/layers/CrossEntropyOverBeam.cpp
paddle/gserver/layers/CrossEntropyOverBeam.cpp
+7
-4
paddle/gserver/layers/CrossEntropyOverBeam.h
paddle/gserver/layers/CrossEntropyOverBeam.h
+3
-3
未找到文件。
paddle/gserver/layers/CrossEntropyOverBeam.cpp
浏览文件 @
36f0aa73
...
@@ -28,8 +28,9 @@ void CostForOneSequence::calValidExpandStep() {
...
@@ -28,8 +28,9 @@ void CostForOneSequence::calValidExpandStep() {
start
,
start
,
start
+
goldRowIds_
[
i
-
1
]
*
beamSize_
+
goldColIds_
[
i
-
1
],
start
+
goldRowIds_
[
i
-
1
]
*
beamSize_
+
goldColIds_
[
i
-
1
],
[](
const
real
&
val
)
{
return
val
!=
-
1.
;
});
[](
const
real
&
val
)
{
return
val
!=
-
1.
;
});
}
else
}
else
{
goldRowIds_
[
i
]
=
0
;
goldRowIds_
[
i
]
=
0
;
}
real
*
start
=
real
*
start
=
beams_
->
candidateIds
[
i
]
->
getData
()
+
goldRowIds_
[
i
]
*
beamSize_
;
beams_
->
candidateIds
[
i
]
->
getData
()
+
goldRowIds_
[
i
]
*
beamSize_
;
...
@@ -288,7 +289,7 @@ void CrossEntropyOverBeam::copyInputsToCpu() {
...
@@ -288,7 +289,7 @@ void CrossEntropyOverBeam::copyInputsToCpu() {
void
CrossEntropyOverBeam
::
splitBatchBeams
()
{
void
CrossEntropyOverBeam
::
splitBatchBeams
()
{
beamCosts_
.
resize
(
batchSize_
);
beamCosts_
.
resize
(
batchSize_
);
beamPerSeq_
.
resize
(
batchSize_
,
beamExpanCount_
);
beamPerSeq_
.
resize
(
batchSize_
,
BeamExpansion
(
beamExpanCount_
)
);
for
(
size_t
i
=
0
;
i
<
beamExpanCount_
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
beamExpanCount_
;
++
i
)
{
int
*
seqStarts
=
int
*
seqStarts
=
...
@@ -300,8 +301,9 @@ void CrossEntropyOverBeam::splitBatchBeams() {
...
@@ -300,8 +301,9 @@ void CrossEntropyOverBeam::splitBatchBeams() {
subSeqStarts
=
subSeqStarts
=
getInput
(
i
*
3
).
subSequenceStartPositions
->
getMutableData
(
false
);
getInput
(
i
*
3
).
subSequenceStartPositions
->
getMutableData
(
false
);
maxLen
=
getInput
(
i
*
3
).
subSequenceStartPositions
->
getSize
()
-
1
;
maxLen
=
getInput
(
i
*
3
).
subSequenceStartPositions
->
getSize
()
-
1
;
}
else
}
else
{
maxLen
=
getInput
(
i
).
sequenceStartPositions
->
getSize
()
-
1
;
maxLen
=
getInput
(
i
).
sequenceStartPositions
->
getSize
()
-
1
;
}
for
(
size_t
j
=
0
;
j
<
batchSize_
;
++
j
)
{
for
(
size_t
j
=
0
;
j
<
batchSize_
;
++
j
)
{
beamPerSeq_
[
j
].
scores
[
i
]
=
beamPerSeq_
[
j
].
scores
[
i
]
=
...
@@ -348,8 +350,9 @@ void CrossEntropyOverBeam::resizeOutput() {
...
@@ -348,8 +350,9 @@ void CrossEntropyOverBeam::resizeOutput() {
inGrad
->
getWidth
(),
inGrad
->
getWidth
(),
false
,
false
,
false
);
false
);
}
else
}
else
{
candidateScoreGrad_
[
i
]
=
std
::
move
(
inGrad
);
candidateScoreGrad_
[
i
]
=
std
::
move
(
inGrad
);
}
candidateScoreGrad_
[
i
]
->
zeroMem
();
candidateScoreGrad_
[
i
]
->
zeroMem
();
}
}
}
}
...
...
paddle/gserver/layers/CrossEntropyOverBeam.h
浏览文件 @
36f0aa73
...
@@ -31,7 +31,7 @@ struct BeamExpansion {
...
@@ -31,7 +31,7 @@ struct BeamExpansion {
size_t
expansionCount
;
size_t
expansionCount
;
BeamExpansion
(
int
n
)
{
explicit
BeamExpansion
(
int
n
)
{
expansionCount
=
n
;
expansionCount
=
n
;
scores
.
resize
(
expansionCount
);
scores
.
resize
(
expansionCount
);
seqInfo
.
resize
(
expansionCount
);
seqInfo
.
resize
(
expansionCount
);
...
@@ -39,7 +39,7 @@ struct BeamExpansion {
...
@@ -39,7 +39,7 @@ struct BeamExpansion {
scoreGrad
.
resize
(
expansionCount
);
scoreGrad
.
resize
(
expansionCount
);
gold
.
resize
(
expansionCount
);
gold
.
resize
(
expansionCount
);
}
;
}
};
};
typedef
std
::
shared_ptr
<
BeamExpansion
>
BeamExpansionPtr
;
typedef
std
::
shared_ptr
<
BeamExpansion
>
BeamExpansionPtr
;
...
@@ -74,7 +74,7 @@ private:
...
@@ -74,7 +74,7 @@ private:
CHECK_GT
(
beams_
->
seqInfo
[
beamId
]
->
getSize
()
-
1
,
rowId
);
CHECK_GT
(
beams_
->
seqInfo
[
beamId
]
->
getSize
()
-
1
,
rowId
);
int
*
starts
=
beams_
->
seqInfo
[
beamId
]
->
getData
();
int
*
starts
=
beams_
->
seqInfo
[
beamId
]
->
getData
();
return
starts
[
rowId
]
-
starts
[
0
];
return
starts
[
rowId
]
-
starts
[
0
];
}
;
}
size_t
beamSize_
;
size_t
beamSize_
;
size_t
validExpansionCount_
;
size_t
validExpansionCount_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录