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
cf43c58c
Commit
cf43c58c
authored
Sep 17, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new code
parent
56326405
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
7 行删除
+24
-7
source/sample/transformer/T2TEncoder.cpp
+0
-2
source/sample/transformer/T2TFNN.cpp
+1
-1
source/sample/transformer/T2TTrainer.cpp
+22
-3
source/sample/transformer/T2TTrainer.h
+1
-1
没有找到文件。
source/sample/transformer/T2TEncoder.cpp
查看文件 @
cf43c58c
...
...
@@ -109,8 +109,6 @@ XTensor AttEncoder::Make(XTensor &input, XTensor &mask, bool skipInputRes, bool
XTensor
fnn
;
XTensor
res
;
llnum
=
-
1
;
/* we skip the residual connection for the first layer if
the encoder is used in language modeling. */
if
(
skipInputRes
&&
i
==
0
){
...
...
source/sample/transformer/T2TFNN.cpp
查看文件 @
cf43c58c
...
...
@@ -58,7 +58,7 @@ void T2TFNN::InitModel(int argc, const char ** argv, int myDevID, XMem * myMem)
LoadParamInt
(
argc
,
argv
,
"d"
,
&
inSize
,
DEFAULT_EMBEDDING_SIZE
);
LoadParamInt
(
argc
,
argv
,
"d"
,
&
outSize
,
DEFAULT_EMBEDDING_SIZE
);
LoadParamInt
(
argc
,
argv
,
"fnnh"
,
&
hSize
,
DEFAULT_EMBEDDING_SIZE
);
LoadParamInt
(
argc
,
argv
,
"fnnh"
,
&
hSize
,
DEFAULT_EMBEDDING_SIZE
*
4
);
LoadParamFloat
(
argc
,
argv
,
"fnnminmax"
,
&
minmax
,
0.1
F
);
InitTensor2D
(
&
w1
,
inSize
,
hSize
,
X_FLOAT
,
devID
,
mem
);
...
...
source/sample/transformer/T2TTrainer.cpp
查看文件 @
cf43c58c
...
...
@@ -325,11 +325,19 @@ void T2TTrainer::Test(const char * fn, const char * ofn, T2TModel * model)
char
line
[
MAX_SEQUENCE_LENGTH
];
struct
SampleNode
{
int
id
;
int
size
;
};
/*
load data to buffer
>> file - where to load data
>> isSorted - indicates whether the samples are sorted by length
>> step - the number of sequences we go over when move to the next sample
*/
int
T2TTrainer
::
LoadBuf
(
FILE
*
file
)
int
T2TTrainer
::
LoadBuf
(
FILE
*
file
,
bool
isSorted
,
int
step
)
{
int
lineCount
=
0
;
int
seqCount
=
0
;
...
...
@@ -395,6 +403,17 @@ int T2TTrainer::LoadBuf(FILE * file)
nseqBuf
=
seqCount
;
nextSeq
=
0
;
if
(
isSorted
)
{
SampleNode
*
nodes
=
new
SampleNode
[
seqCount
];
int
count
=
0
;
for
(
int
i
=
0
;
i
<
seqCount
;
i
+=
step
)
{
nodes
[
count
].
id
=
count
;
nodes
[
count
].
size
=
seqLen
[
i
];
count
++
;
}
delete
[]
nodes
;
}
return
lineCount
;
}
...
...
@@ -422,7 +441,7 @@ load a batch of sequences
>> devID - device id
>> mem - memory pool
*/
int
T2TTrainer
::
LoadBatch
(
FILE
*
file
,
bool
isLM
,
int
T2TTrainer
::
LoadBatch
(
FILE
*
file
,
bool
isLM
,
XTensor
*
batch
,
XTensor
*
padding
,
XTensor
*
output
,
int
*
seqs
,
int
step
,
int
vs
,
int
sBatch
,
int
wBatch
,
...
...
@@ -430,7 +449,7 @@ int T2TTrainer::LoadBatch(FILE * file, bool isLM,
int
devID
,
XMem
*
mem
)
{
if
(
nextSeq
<
0
||
nextSeq
>=
nseqBuf
)
LoadBuf
(
file
);
LoadBuf
(
file
,
isSorted
);
int
seq
=
MAX
(
nextSeq
,
0
);
int
wc
=
0
;
...
...
source/sample/transformer/T2TTrainer.h
查看文件 @
cf43c58c
...
...
@@ -118,7 +118,7 @@ public:
void
Test
(
const
char
*
fn
,
const
char
*
ofn
,
T2TModel
*
model
);
/* load data to buffer */
int
LoadBuf
(
FILE
*
file
);
int
LoadBuf
(
FILE
*
file
,
bool
isSorted
,
int
step
);
/* clear data buffer */
void
ClearBuf
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论