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
杨迪
NiuTrans.Tensor
Commits
c090457f
Commit
c090457f
authored
Sep 25, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test code
parent
907f7d2a
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
31 行增加
和
8 行删除
+31
-8
source/network/XNet.cpp
+2
-0
source/sample/transformer/T2TTrainer.cpp
+7
-0
source/tensor/XLink.cpp
+18
-8
source/tensor/XLink.h
+4
-0
没有找到文件。
source/network/XNet.cpp
查看文件 @
c090457f
...
@@ -303,6 +303,8 @@ void XNet::TarjanVisit(XTensor * node, XList &orders, const unsigned int code)
...
@@ -303,6 +303,8 @@ void XNet::TarjanVisit(XTensor * node, XList &orders, const unsigned int code)
node
->
visitMark
=
code
+
2
;
node
->
visitMark
=
code
+
2
;
orders
.
Add
(
node
);
orders
.
Add
(
node
);
}
}
else
if
(
node
->
visitMark
==
code
+
2
){
}
}
}
/*
/*
...
...
source/sample/transformer/T2TTrainer.cpp
查看文件 @
c090457f
...
@@ -217,6 +217,13 @@ void T2TTrainer::Train(const char * fn, const char * validFN, const char * model
...
@@ -217,6 +217,13 @@ void T2TTrainer::Train(const char * fn, const char * validFN, const char * model
/* back-propagation */
/* back-propagation */
net
.
Backward
(
output
,
g
,
CROSSENTROPY
);
net
.
Backward
(
output
,
g
,
CROSSENTROPY
);
/*for(int i = 0; i < net.nodes.count; i++){
XTensor * node = (XTensor*)net.nodes.Get(i);
XLink::ShowNode(stderr, node);
}
exit(0);*/
gradStep
+=
1
;
gradStep
+=
1
;
loss
+=
-
prob
;
loss
+=
-
prob
;
wordCount
+=
wc
;
wordCount
+=
wc
;
...
...
source/tensor/XLink.cpp
查看文件 @
c090457f
...
@@ -589,9 +589,24 @@ show the network encoded in a root node (tensor)
...
@@ -589,9 +589,24 @@ show the network encoded in a root node (tensor)
*/
*/
void
XLink
::
ShowNetwork
(
FILE
*
file
,
XTensor
*
root
)
void
XLink
::
ShowNetwork
(
FILE
*
file
,
XTensor
*
root
)
{
{
fprintf
(
file
,
"node %d - "
,
root
->
id
);
XLink
&
income
=
root
->
income
;
XLink
&
income
=
root
->
income
;
for
(
int
i
=
0
;
i
<
income
.
tailNum
;
i
++
){
XTensor
*
child
=
income
.
tails
[
i
];
ShowNetwork
(
file
,
child
);
}
}
/*
show a node
>> file - file to dump information
>> root - pointer to the node
*/
void
XLink
::
ShowNode
(
FILE
*
file
,
XTensor
*
node
)
{
fprintf
(
file
,
"node %d - "
,
node
->
id
);
XLink
&
income
=
node
->
income
;
if
(
income
.
head
==
NULL
){
if
(
income
.
head
==
NULL
){
fprintf
(
file
,
"income[%d]: null "
,
income
.
tailNum
);
fprintf
(
file
,
"income[%d]: null "
,
income
.
tailNum
);
}
}
...
@@ -607,7 +622,7 @@ void XLink::ShowNetwork(FILE * file, XTensor * root)
...
@@ -607,7 +622,7 @@ void XLink::ShowNetwork(FILE * file, XTensor * root)
}
}
fprintf
(
stderr
,
", "
);
fprintf
(
stderr
,
", "
);
XLink
&
outgo
=
root
->
outgo
;
XLink
&
outgo
=
node
->
outgo
;
if
(
outgo
.
head
==
NULL
||
outgo
.
tailNum
==
0
){
if
(
outgo
.
head
==
NULL
||
outgo
.
tailNum
==
0
){
fprintf
(
file
,
"outgo[%d]: null "
,
outgo
.
tailNum
);
fprintf
(
file
,
"outgo[%d]: null "
,
outgo
.
tailNum
);
}
}
...
@@ -623,11 +638,6 @@ void XLink::ShowNetwork(FILE * file, XTensor * root)
...
@@ -623,11 +638,6 @@ void XLink::ShowNetwork(FILE * file, XTensor * root)
}
}
fprintf
(
stderr
,
"
\n
"
);
fprintf
(
stderr
,
"
\n
"
);
for
(
int
i
=
0
;
i
<
income
.
tailNum
;
i
++
){
XTensor
*
child
=
income
.
tails
[
i
];
ShowNetwork
(
file
,
child
);
}
}
}
}
// namespace nts(NiuTrans.Tensor)
}
// namespace nts(NiuTrans.Tensor)
...
...
source/tensor/XLink.h
查看文件 @
c090457f
...
@@ -178,6 +178,10 @@ struct XLink
...
@@ -178,6 +178,10 @@ struct XLink
/* show the network encoded in a root node (tensor) */
/* show the network encoded in a root node (tensor) */
static
static
void
ShowNetwork
(
FILE
*
file
,
XTensor
*
root
);
void
ShowNetwork
(
FILE
*
file
,
XTensor
*
root
);
/* show a node */
static
void
ShowNode
(
FILE
*
file
,
XTensor
*
node
);
};
};
}
// namespace nts(NiuTrans.Tensor)
}
// namespace nts(NiuTrans.Tensor)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论