Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
03fed61d
Commit
03fed61d
authored
Apr 22, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
heap of each sentence
parent
fdd64fb0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
8 行删除
+23
-8
source/sample/transformer/T2TSearch.cpp
+20
-5
source/sample/transformer/T2TSearch.h
+3
-3
没有找到文件。
source/sample/transformer/T2TSearch.cpp
查看文件 @
03fed61d
...
...
@@ -27,6 +27,19 @@ using namespace nts;
namespace
transformer
{
/* constructor */
T2TSearch
::
T2TSearch
()
{
fullHypos
=
NULL
;
}
/* de-constructor */
T2TSearch
::~
T2TSearch
()
{
if
(
fullHypos
!=
NULL
)
delete
[]
fullHypos
;
}
/*
initialize the model
...
...
@@ -93,13 +106,13 @@ prepare for search
*/
void
T2TSearch
::
Prepare
(
int
batchSize
,
int
beamSize
)
{
if
(
heap
s
!=
NULL
)
delete
[]
heap
s
;
if
(
fullHypo
s
!=
NULL
)
delete
[]
fullHypo
s
;
heap
s
=
new
XHeap
<
MIN_HEAP
,
float
>
[
batchSize
];
fullHypo
s
=
new
XHeap
<
MIN_HEAP
,
float
>
[
batchSize
];
for
(
int
i
=
0
;
i
<
batchSize
;
i
++
)
heap
s
[
i
].
Init
(
beamSize
);
fullHypo
s
[
i
].
Init
(
beamSize
);
}
/*
...
...
@@ -254,7 +267,7 @@ void T2TSearch::Expand(T2TStateBundle * prev, T2TStateBundle * beam)
}
/*
collect hypotheses with ending symbol. Given a beam of hypotheses,
collect hypotheses with ending symbol
s
. Given a beam of hypotheses,
we remove the finished hypotheses and keep them in a heap.
>> beam - the beam that keeps a number of states
*/
...
...
@@ -264,6 +277,8 @@ void T2TSearch::Collect(T2TStateBundle * beam)
for
(
int
i
=
0
;
i
<
beam
->
stateNum
;
i
++
)
{
T2TState
&
state
=
states
[
i
];
state
.
pid
=
state
.
last
->
pid
;
}
}
...
...
source/sample/transformer/T2TSearch.h
查看文件 @
03fed61d
...
...
@@ -48,14 +48,14 @@ private:
int
beamSize
;
/* we keep the final hypotheses in a heap for each sentence in the batch. */
XHeap
<
MIN_HEAP
,
float
>
*
heap
s
;
XHeap
<
MIN_HEAP
,
float
>
*
fullHypo
s
;
public
:
/* constructor */
T2TSearch
()
{}
;
T2TSearch
();
/* de-constructor */
~
T2TSearch
()
{}
;
~
T2TSearch
();
/* initialize the model */
void
InitModel
(
int
argc
,
char
**
argv
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论