Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
7a42c92d
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看板
提交
7a42c92d
编写于
8月 24, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix a bug that memory does not clean.
上级
74d3ca8b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
13 addition
and
8 deletion
+13
-8
paddle/gserver/layers/CrossEntropyOverBeam.cpp
paddle/gserver/layers/CrossEntropyOverBeam.cpp
+13
-8
未找到文件。
paddle/gserver/layers/CrossEntropyOverBeam.cpp
浏览文件 @
7a42c92d
...
...
@@ -53,8 +53,8 @@ size_t CostForOneSequence::initLastExpansion() {
candidates
->
getData
()
+
height
*
beamSize_
,
[](
const
real
&
val
)
{
return
val
!=
-
1
;
});
/*
* if the gold sequence falls off the beam during search,
*
add the gold sequence as the last path into all expanded path
s.
* if the gold sequence falls off the beam during search,
add the gold
*
sequence as the last path into the all expanded candidate
s.
*/
if
(
goldAsExtraPath_
)
goldIdsInFinalExpansion_
=
pathCount
++
;
...
...
@@ -133,7 +133,7 @@ real CostForOneSequence::globallyNormalizedScore() {
Matrix
::
resizeOrCreate
(
softmaxOut_
,
1
,
pathRowIdsInEachBeam_
[
0
].
size
(),
false
,
false
);
softmaxOut_
->
zero
();
softmaxOut_
->
zero
Mem
();
MatrixPtr
tmp
=
Matrix
::
create
(
softmaxOut_
->
getData
(),
softmaxOut_
->
getWidth
(),
1
,
false
,
false
);
...
...
@@ -143,6 +143,8 @@ real CostForOneSequence::globallyNormalizedScore() {
1
,
false
,
false
);
expandedPathScores_
[
i
]
->
zeroMem
();
IVectorPtr
rowIds
=
IVector
::
create
(
pathRowIdsInEachBeam_
[
i
].
data
(),
pathRowIdsInEachBeam_
[
i
].
size
(),
false
);
...
...
@@ -217,13 +219,16 @@ void CrossEntropyOverBeam::checkInputs() {
const
Argument
&
goldSeq
=
getInput
(
i
*
3
+
2
);
if
(
i
)
{
CHECK
(
scores
.
hasSubseq
())
<<
"Beam expansion expect the first one, "
"should be a nested sequence"
;
CHECK
(
scores
.
hasSubseq
())
<<
"input "
<<
i
<<
" "
<<
inputLayers_
[
i
*
3
]
->
getName
()
<<
" should be a nested sequence"
;
CHECK_EQ
(
getInputValue
(
i
*
3
+
1
)
->
getWidth
(),
beamSize_
);
CHECK_EQ
(
scores
.
getNumSequences
(),
batchSize_
);
CHECK_EQ
(
scores
.
getNumSubSequences
(),
selCandidates
.
getBatchSize
());
}
else
{
CHECK
(
scores
.
hasSeq
())
<<
"The first beam expansion should be a sequence"
;
CHECK
(
scores
.
hasSeq
())
<<
"input "
<<
i
<<
" "
<<
inputLayers_
[
i
]
->
getName
()
<<
" should be a sequence"
;
batchSize_
=
scores
.
getNumSequences
();
beamSize_
=
getInputValue
(
i
*
3
+
1
)
->
getWidth
();
CHECK_EQ
(
batchSize_
,
selCandidates
.
getBatchSize
());
...
...
@@ -332,7 +337,7 @@ void CrossEntropyOverBeam::splitBatchBeams() {
void
CrossEntropyOverBeam
::
resizeOutput
()
{
Matrix
::
resizeOrCreate
(
output_
.
value
,
batchSize_
,
1
,
false
,
false
);
output_
.
value
->
zero
();
output_
.
value
->
zero
Mem
();
for
(
size_t
i
=
0
;
i
<
beamExpanCount_
;
++
i
)
{
MatrixPtr
inGrad
=
getInputGrad
(
i
*
3
);
...
...
@@ -344,7 +349,7 @@ void CrossEntropyOverBeam::resizeOutput() {
false
);
}
else
candidateScoreGrad_
[
i
]
=
std
::
move
(
inGrad
);
candidateScoreGrad_
[
i
]
->
zero
();
candidateScoreGrad_
[
i
]
->
zero
Mem
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录