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
a84f1cb0
Commit
a84f1cb0
authored
Mar 24, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add maps of parameters and gradients for a group of models
parent
ee577b38
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
2 行删除
+43
-2
source/train/TTrain.cpp
+0
-2
source/train/XLeader.cpp
+24
-0
source/train/XLeader.h
+19
-0
没有找到文件。
source/train/TTrain.cpp
查看文件 @
a84f1cb0
...
@@ -95,8 +95,6 @@ void TestTrain()
...
@@ -95,8 +95,6 @@ void TestTrain()
TTModel
model
;
TTModel
model
;
model
.
Init
(
config
,
serverDevID
);
model
.
Init
(
config
,
serverDevID
);
tmpTT
=
model
.
params
[
0
].
param
;
XOptimizer
optimizer
;
XOptimizer
optimizer
;
optimizer
.
Init
(
config
);
optimizer
.
Init
(
config
);
...
...
source/train/XLeader.cpp
查看文件 @
a84f1cb0
...
@@ -40,11 +40,15 @@ namespace nts {
...
@@ -40,11 +40,15 @@ namespace nts {
XLeader
::
XLeader
()
XLeader
::
XLeader
()
{
{
id
=
-
1
;
id
=
-
1
;
paramMap
=
NULL
;
gradMap
=
NULL
;
modelNum
=
0
;
}
}
/* de-constructor */
/* de-constructor */
XLeader
::~
XLeader
()
XLeader
::~
XLeader
()
{
{
DestroyParamMap
();
}
}
/* intialize the leader */
/* intialize the leader */
...
@@ -403,6 +407,26 @@ bool XLeader::Run(XConfig * config, DataDistributeBase * dataDistributor, XOptim
...
@@ -403,6 +407,26 @@ bool XLeader::Run(XConfig * config, DataDistributeBase * dataDistributor, XOptim
return
activeJobCount
>
0
;
return
activeJobCount
>
0
;
}
}
/* destroy the parameter map (and gradient map) */
void
XLeader
::
DestroyParamMap
()
{
for
(
int
i
=
0
;
i
<
modelNum
;
i
++
){
delete
[]
paramMap
[
i
];
delete
[]
gradMap
[
i
];
}
delete
[]
paramMap
;
delete
[]
gradMap
;
modelNum
=
0
;
}
/* generate the map of parameters */
void
XLeader
::
MakeParamMap
()
{
DestroyParamMap
();
for
(
int
i
=
0
;
i
<
jworkers
.
count
;
i
++
){
}
}
/*
/*
run the model
run the model
>> config - the configuration
>> config - the configuration
...
...
source/train/XLeader.h
查看文件 @
a84f1cb0
...
@@ -95,6 +95,19 @@ protected:
...
@@ -95,6 +95,19 @@ protected:
of jobs. */
of jobs. */
XList
pworkers
;
XList
pworkers
;
/* map of parameters. (x,y) indexes parameter x of
worker y. Note that a worker keeps a copy of the
parameters and runs back-propagation to obtain the
gradient of the loss with respect to the parameters. */
XTensorKeeper
**
paramMap
;
/* map of parameter gradients. (x,y) indexes the
gradient of parameter x of worker y. */
XTensorKeeper
**
gradMap
;
/* number of model copies for paramMap and gradMap */
int
modelNum
;
public
:
public
:
/* constructor */
/* constructor */
XLeader
();
XLeader
();
...
@@ -162,6 +175,12 @@ public:
...
@@ -162,6 +175,12 @@ public:
/* add a parameter worker (or a pipeline) */
/* add a parameter worker (or a pipeline) */
void
AddJobParamterWorker
(
int
n
);
void
AddJobParamterWorker
(
int
n
);
/* destroy the parameter map (and gradient map) */
void
DestroyParamMap
();
/* generate the map of parameters */
void
MakeParamMap
();
/* run the model and update it (for one time) */
/* run the model and update it (for one time) */
bool
Run
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
XOptimizer
*
optimizer
);
bool
Run
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
XOptimizer
*
optimizer
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论