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
3bc771f4
Commit
3bc771f4
authored
Mar 17, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates
parent
b199a6ee
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
19 行删除
+14
-19
source/sample/transformer/Model.h
+11
-3
source/sample/transformer/train/TrainDataSet.h
+3
-16
没有找到文件。
source/sample/transformer/Model.h
查看文件 @
3bc771f4
...
@@ -24,17 +24,18 @@
...
@@ -24,17 +24,18 @@
#include "Encoder.h"
#include "Encoder.h"
#include "Decoder.h"
#include "Decoder.h"
#include "Utility.h"
#include "submodel/FNN.h"
#include "submodel/FNN.h"
#include "submodel/Output.h"
#include "submodel/Output.h"
#include "Utility.h"
#include "submodel/Attention.h"
#include "submodel/Attention.h"
#include "../../train/XModel.h"
namespace
nmt
namespace
nmt
{
{
/* a nmt model that keeps parameters of the encoder,
/* a
n
nmt model that keeps parameters of the encoder,
the decoder and the output layer (softmax). */
the decoder and the output layer (softmax). */
class
Model
class
Model
:
public
XModel
{
{
public
:
public
:
/* device id */
/* device id */
...
@@ -114,6 +115,13 @@ public:
...
@@ -114,6 +115,13 @@ public:
/* read the parameters */
/* read the parameters */
void
Read
(
FILE
*
file
);
void
Read
(
FILE
*
file
);
public
:
/* clone the model (overloaded method of XModel) */
XModel
*
Clone
(
int
devID
);
/* run the neural network (overloaded method of XModel) */
bool
RunSimple
(
XList
*
inputs
,
XList
*
outputs
,
XList
*
golds
,
XList
*
losses
);
};
};
}
}
...
...
source/sample/transformer/train/TrainDataSet.h
查看文件 @
3bc771f4
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "../../../tensor/XList.h"
#include "../../../tensor/XList.h"
#include "../../../tensor/XTensor.h"
#include "../../../tensor/XTensor.h"
#include "../../../tensor/XGlobal.h"
#include "../../../tensor/XGlobal.h"
#include "../../../train/XBaseTemplate.h"
#define MAX_WORD_NUM 120
#define MAX_WORD_NUM 120
...
@@ -56,7 +57,8 @@ struct TrainExample {
...
@@ -56,7 +57,8 @@ struct TrainExample {
};
};
/* A `TrainDataSet` is associated with a file which contains training data. */
/* A `TrainDataSet` is associated with a file which contains training data. */
struct
TrainDataSet
{
struct
TrainDataSet
:
public
DataDistributeBase
{
public
:
public
:
/* the data buffer */
/* the data buffer */
TrainBufferType
buffer
;
TrainBufferType
buffer
;
...
@@ -98,21 +100,6 @@ public:
...
@@ -98,21 +100,6 @@ public:
XTensor
*
batchDec
,
XTensor
*
paddingDec
,
XTensor
*
label
,
XTensor
*
batchDec
,
XTensor
*
paddingDec
,
XTensor
*
label
,
size_t
minSentBatch
,
size_t
batchSize
,
int
devID
);
size_t
minSentBatch
,
size_t
batchSize
,
int
devID
);
/* load the samples into the buffer (a list) */
bool
LoadBatchToBuf
(
XList
*
buf
);
/* load the samples into tensors from the buffer */
static
bool
LoadBatch
(
XList
*
buf
,
XTensor
*
batchEnc
,
XTensor
*
paddingEnc
,
XTensor
*
batchDec
,
XTensor
*
paddingDec
,
XTensor
*
label
,
size_t
minSentBatch
,
size_t
batchSize
,
int
devID
,
int
&
wc
,
int
&
sc
);
/* release the samples in a buffer */
static
void
ClearSamples
(
XList
*
buf
);
/* initialization function */
/* initialization function */
void
Init
(
const
char
*
dataFile
,
int
bucketSize
,
bool
training
);
void
Init
(
const
char
*
dataFile
,
int
bucketSize
,
bool
training
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论