Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
Emmay
NiuTrans.Tensor
Commits
7d201bf2
Commit
7d201bf2
authored
Aug 01, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless code and fix bugs
parent
aac1ad5c
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
19 行增加
和
11 行删除
+19
-11
source/network/Main.cpp
+0
-2
source/network/XBackwardMath.cpp
+12
-2
source/sample/fnnlm/FNNLM.cpp
+0
-1
source/sample/transformer/T2TAttention.cpp
+1
-0
source/sample/transformer/T2TEmbedding.cpp
+1
-1
source/sample/transformer/T2TEncoder.cpp
+5
-5
没有找到文件。
source/network/Main.cpp
查看文件 @
7d201bf2
...
...
@@ -175,8 +175,6 @@ void SumDimTest()
XTensor
y
;
XTensor
z
;
int
loops
=
2000
;
int
a
=
5
;
int
b
=
7
;
int
c
=
3
;
...
...
source/network/XBackwardMath.cpp
查看文件 @
7d201bf2
...
...
@@ -118,11 +118,16 @@ void XMathGrad::GradSumDim(XTensor * node)
if
(
b
->
outgo
.
tailNum
>
1
){
XTensor
*
bGradTMP
=
NewTensorBuf
(
b
->
grad
,
b
->
devID
,
b
->
mem
);
_ReduceSum
(
node
->
grad
,
bGradTMP
,
0
);
if
(
beta
!=
1.0
F
)
_ScaleAndShiftMe
(
bGradTMP
,
beta
);
_Sum
(
bGradTMP
,
b
->
grad
,
b
->
grad
);
DelTensorBuf
(
bGradTMP
);
}
else
else
{
_ReduceSum
(
node
->
grad
,
b
->
grad
,
0
);
if
(
beta
!=
1.0
F
)
_ScaleAndShiftMe
(
b
->
grad
,
beta
);
}
node
->
grad
->
Reshape
(
order
,
dimSize
);
}
...
...
@@ -150,11 +155,16 @@ void XMathGrad::GradSumDim(XTensor * node)
if
(
b
->
outgo
.
tailNum
>
1
){
XTensor
*
bGradTMP
=
NewTensorBuf
(
b
->
grad
,
b
->
devID
,
b
->
mem
);
_ReduceSum
(
interGrad
,
bGradTMP
,
0
);
if
(
beta
!=
1.0
F
)
_ScaleAndShiftMe
(
bGradTMP
,
beta
);
_Sum
(
bGradTMP
,
b
->
grad
,
b
->
grad
);
DelTensorBuf
(
bGradTMP
);
}
else
else
{
_ReduceSum
(
interGrad
,
b
->
grad
,
0
);
if
(
beta
!=
1.0
F
)
_ScaleAndShiftMe
(
b
->
grad
,
beta
);
}
node
->
grad
->
Reshape
(
order
,
dimSize
);
...
...
source/sample/fnnlm/FNNLM.cpp
查看文件 @
7d201bf2
...
...
@@ -975,7 +975,6 @@ forward process (with tensor connections)
*/
void
ForwardAutoDiff
(
XTensor
inputs
[],
XTensor
&
output
,
FNNModel
&
model
)
{
int
batchSize
=
inputs
[
0
].
GetDim
(
0
);
int
n
=
model
.
n
;
int
depth
=
model
.
hDepth
;
...
...
source/sample/transformer/T2TAttention.cpp
查看文件 @
7d201bf2
...
...
@@ -19,6 +19,7 @@
* $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2018-07-31
*/
#include <math.h>
#include "T2TAttention.h"
#include "T2TUtility.h"
#include "../../tensor/core/CHeader.h"
...
...
source/sample/transformer/T2TEmbedding.cpp
查看文件 @
7d201bf2
...
...
@@ -19,6 +19,7 @@
* $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2018-08-01
*/
#include <math.h>
#include "T2TEmbedding.h"
#include "T2TUtility.h"
#include "../../tensor/core/CHeader.h"
...
...
@@ -51,7 +52,6 @@ void T2TEmbedder::InitModel(int argc, const char ** argv, int myDevID, XMem * my
devID
=
myDevID
;
mem
=
myMem
;
float
minmax
=
0
;
int
maxLength
=
0
;
int
d
=
0
;
...
...
source/sample/transformer/T2TEncoder.cpp
查看文件 @
7d201bf2
...
...
@@ -88,20 +88,20 @@ XTensor * AttEncoder::Make(XTensor * input)
for
(
int
i
=
0
;
i
<
nlayer
;
i
++
){
XTensor
*
att
;
XTensor
*
res
;
XTensor
*
ln
;
XTensor
*
fnn
;
XTensor
res
;
/* self attention */
att
=
attentions
[
i
].
Make
(
x
,
x
,
x
);
/* residual connection */
res
=
&
Sum
(
*
att
,
*
x
);
res
=
Sum
(
*
att
,
*
x
);
/* TODO: dropout */
/* layer normalization */
ln
=
layerNorms
[
i
].
Make
(
res
);
ln
=
layerNorms
[
i
].
Make
(
&
res
);
/* input of next layer */
x
=
ln
;
...
...
@@ -110,12 +110,12 @@ XTensor * AttEncoder::Make(XTensor * input)
fnn
=
fnns
[
i
].
Make
(
x
);
/* residual connection */
res
=
&
Sum
(
*
fnn
,
*
x
);
res
=
Sum
(
*
fnn
,
*
x
);
/* TODO: dropout */
/* layer normalization */
ln
=
layerNorms
[
i
].
Make
(
res
);
ln
=
layerNorms
[
i
].
Make
(
&
res
);
/* input of next layer */
x
=
ln
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论