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
b69e10f6
Commit
b69e10f6
authored
Mar 08, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates
parent
b2be85f1
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
36 行增加
和
13 行删除
+36
-13
source/train/TTrain.cpp
+3
-0
source/train/XLeader.cpp
+6
-0
source/train/XLeader.h
+4
-2
source/train/XNNRecord.cpp
+2
-0
source/train/XNNRecord.h
+4
-2
source/train/XTrainer.cpp
+4
-7
source/train/XWorkerBroadcast.cpp
+1
-2
source/train/XWorkerJob.cpp
+9
-0
source/train/XWorkerJob.h
+3
-0
没有找到文件。
source/train/TTrain.cpp
查看文件 @
b69e10f6
...
...
@@ -306,6 +306,7 @@ run the neural network
*/
bool
TTModel
::
RunSimple
(
XList
*
inputs
,
XList
*
outputs
,
XList
*
golds
,
XList
*
losses
)
{
//fprintf(stderr, "run simple 0\n");
CheckNTErrors
(
inputs
!=
NULL
&&
inputs
->
count
>=
1
,
"Wrong arguments!"
);
CheckNTErrors
(
outputs
!=
NULL
&&
outputs
->
count
>=
1
,
"Wrong arguments!"
);
CheckNTErrors
(
golds
!=
NULL
&&
golds
->
count
>=
1
,
"Wrong arguments!"
);
...
...
@@ -338,6 +339,8 @@ bool TTModel::RunSimple(XList * inputs, XList * outputs, XList * golds, XList* l
net
.
Backward
(
*
loss
);
delete
[]
dims
;
//fprintf(stderr, "run simple 1\n");
return
true
;
}
...
...
source/train/XLeader.cpp
查看文件 @
b69e10f6
...
...
@@ -119,6 +119,12 @@ float XLeader::GetLoss()
{
return
serverRecord
.
lossAll
;
}
/* get sample number */
int
XLeader
::
GetSampleNum
()
{
return
serverRecord
.
sampleNum
;
}
/* get prediction number */
int
XLeader
::
GetPredictNum
()
...
...
source/train/XLeader.h
查看文件 @
b69e10f6
...
...
@@ -111,6 +111,9 @@ public:
/* get loss */
float
GetLoss
();
/* get sample number */
int
GetSampleNum
();
/* get prediction number */
int
GetPredictNum
();
...
...
@@ -143,4 +146,4 @@ public:
}
#endif // __XLEADER_H__
\ No newline at end of file
#endif // __XLEADER_H__
source/train/XNNRecord.cpp
查看文件 @
b69e10f6
...
...
@@ -45,6 +45,7 @@ XNNRecord::~XNNRecord()
void
XNNRecord
::
Clear
()
{
lossAll
=
0
;
sampleNum
=
0
;
predictNum
=
0
;
state
=
XWORKER_UNSTARTED
;
}
...
...
@@ -53,6 +54,7 @@ void XNNRecord::Clear()
void
XNNRecord
::
Update
(
XNNRecord
&
record
)
{
lossAll
+=
record
.
lossAll
;
sampleNum
+=
record
.
sampleNum
;
predictNum
+=
record
.
predictNum
;
}
...
...
source/train/XNNRecord.h
查看文件 @
b69e10f6
...
...
@@ -39,6 +39,9 @@ class XNNRecord
public
:
/* loss over all samples */
float
lossAll
;
/* sample number */
int
sampleNum
;
/* prediction number */
int
predictNum
;
...
...
@@ -61,4 +64,4 @@ public:
};
}
#endif
\ No newline at end of file
#endif
source/train/XTrainer.cpp
查看文件 @
b69e10f6
...
...
@@ -103,9 +103,6 @@ void XTrainer::Run(XConfig * config, DataDistributeBase * dataDistributor,
int
*
ids
=
new
int
[
MAX_DEVICE_NUM_TRAINING
];
GetDevIDs
(
config
,
ids
,
jobNum
,
MAX_DEVICE_NUM_TRAINING
);
float
lossAll
=
0
;
int
predictNum
=
0
;
/* create the server and workers */
XLeader
leader
;
leader
.
Init
();
...
...
@@ -127,11 +124,11 @@ void XTrainer::Run(XConfig * config, DataDistributeBase * dataDistributor,
/* one step of udpate */
ok
=
leader
.
Run
(
config
,
dataDistributor
,
model
,
optimizer
);
float
loss
=
leader
.
GetLoss
()
/
leader
.
Get
Predict
Num
();
float
loss
=
leader
.
GetLoss
()
/
leader
.
Get
Sample
Num
();
if
((
step
+
1
)
%
1
00
==
0
)
fprintf
(
stderr
,
"epoch:%d step:%d
loss:%f predict:%d
\n
"
,
epoch
+
1
,
step
+
1
,
loss
,
leader
.
GetPredictNum
());
if
((
step
+
1
)
%
1
==
0
)
fprintf
(
stderr
,
"epoch:%d step:%d
sample:%d loss:%f predict:%d
\n
"
,
epoch
+
1
,
step
+
1
,
l
eader
.
GetSampleNum
(),
l
oss
,
leader
.
GetPredictNum
());
if
(
step
++
>=
nstep
)
break
;
...
...
source/train/XWorkerBroadcast.cpp
查看文件 @
b69e10f6
...
...
@@ -144,4 +144,4 @@ bool XWorkerBroadcast::AddJobBroadcast(XModel * source, XList * targetList)
return
true
;
}
}
\ No newline at end of file
}
source/train/XWorkerJob.cpp
查看文件 @
b69e10f6
...
...
@@ -134,13 +134,16 @@ XNNRecord * XWorkerJob::GetRecord()
void
XWorkerJob
::
RecordMe
()
{
float
lossAll
=
0
;
int
sampleNum
=
0
;
for
(
int
i
=
0
;
i
<
losses
.
count
;
i
++
)
{
XTensor
*
loss
=
(
XTensor
*
)
losses
[
i
];
lossAll
+=
ReduceSumAllValue
(
*
loss
);
sampleNum
+=
loss
->
GetSize
();
}
record
.
lossAll
=
lossAll
;
record
.
sampleNum
=
sampleNum
;
int
predictNum
=
0
;
...
...
@@ -157,6 +160,12 @@ float XWorkerJob::GetLossAll()
{
return
record
.
lossAll
;
}
/* get the number of samples */
int
XWorkerJob
::
GetSampleNum
()
{
return
record
.
sampleNum
;
}
/* get the number of outputs (predictoins) */
int
XWorkerJob
::
GetPredictNum
()
...
...
source/train/XWorkerJob.h
查看文件 @
b69e10f6
...
...
@@ -99,6 +99,9 @@ public:
/* get the sum of losses over samples */
float
GetLossAll
();
/* get the number of samples */
int
GetSampleNum
();
/* get the number of outputs (predictoins) */
int
GetPredictNum
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论