-
Notifications
You must be signed in to change notification settings - Fork 1k
模型增量导出
songyue1104 edited this page Aug 12, 2019
·
1 revision
- 训练过程中将模型增量以文件的形式导出至HDFS
- 在任务的配置文件中添加增量上传的目录路径。具体的配置选项如下(如果配置选项为空,则本功能未开启):
"streaming_output": {
"dense":{
"addr": "hdfs_path"
},
"sparse":{
"addr": "hdfs_path"
},
"hash":{
"addr": "hdfs_path"
}
}
- 在训练代码中增加如下三个hook:DenseIncreaseStreamHook,DenseIncreaseStreamHook,SparseIncreaseStreamHook。参数为训练的global step的间隔,每间隔参数指定的步数后作一次模型增量上传。单次模型增量会上传至目录inc-788899999(数字为当前的global step步数)下。使用的示例代码如下:
if (xdl.get_task_index() == 1):
hooks.append(DenseIncreaseStreamHook(2000000))
hooks.append(HashIncreaseStreamHook(2000000))
hooks.append(SparseIncreaseStreamHook(2000000))
- 增量模型为pb格式,具体定义如下:
message TensorData {
repeated int64 shape = 1;
optional int32 type = 2;
optional bytes value = 3;
}
message DenseVar {
optional string name = 1;
optional TensorData value = 2;
}
message DenseModel {
repeated DenseVar dense_vars = 1;
}
message SparseVar {
optional string name = 1;
optional TensorData ids = 2;
optional TensorData value = 3;
optional TensorData del_ids = 4;
}
message SparseModel {
repeated SparseVar sparse_vars = 1;
}