Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
65afbe11
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
692
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65afbe11
编写于
7月 03, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"fix gob register error"
上级
e6c98e49
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
15 deletion
+18
-15
go/pserver/service.go
go/pserver/service.go
+18
-15
未找到文件。
go/pserver/service.go
浏览文件 @
65afbe11
...
@@ -25,7 +25,7 @@ const (
...
@@ -25,7 +25,7 @@ const (
)
)
const
(
const
(
checkpoint_path
=
"/checkpoints/"
checkpoint_path
=
"
.
/checkpoints/"
)
)
// Supported element types
// Supported element types
...
@@ -67,10 +67,10 @@ type Service struct {
...
@@ -67,10 +67,10 @@ type Service struct {
optMap
map
[
string
]
*
optimizer
optMap
map
[
string
]
*
optimizer
}
}
type
C
heckpoint
struct
{
type
c
heckpoint
struct
{
u
uid
string
U
uid
string
m
d5sum
string
M
d5sum
string
t
imestamp
string
T
imestamp
string
}
}
//serialize ParameterWithConfig to byte stream
//serialize ParameterWithConfig to byte stream
...
@@ -93,6 +93,8 @@ func NewService(idx int) (*Service, error) {
...
@@ -93,6 +93,8 @@ func NewService(idx int) (*Service, error) {
}
}
s
.
optMap
=
make
(
map
[
string
]
*
optimizer
)
s
.
optMap
=
make
(
map
[
string
]
*
optimizer
)
s
.
initialized
=
make
(
chan
struct
{})
s
.
initialized
=
make
(
chan
struct
{})
gob
.
Register
(
ParameterWithConfig
{})
gob
.
Register
(
checkpoint
{})
return
s
,
nil
return
s
,
nil
}
}
...
@@ -190,32 +192,33 @@ func (s *Service) Save(path string, dummy *int) error {
...
@@ -190,32 +192,33 @@ func (s *Service) Save(path string, dummy *int) error {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorln
(
err
)
log
.
Errorln
(
err
)
}
}
ck
:=
C
heckpoint
{}
ck
:=
c
heckpoint
{}
h
:=
md5
.
New
()
h
:=
md5
.
New
()
ck
.
m
d5sum
=
hex
.
EncodeToString
(
h
.
Sum
(
content
))
ck
.
M
d5sum
=
hex
.
EncodeToString
(
h
.
Sum
(
content
))
ck
.
t
imestamp
=
time
.
Now
()
.
String
()
ck
.
T
imestamp
=
time
.
Now
()
.
String
()
ck
.
u
uid
=
checkpoint_path
+
strconv
.
Itoa
(
s
.
idx
)
ck
.
U
uid
=
checkpoint_path
+
strconv
.
Itoa
(
s
.
idx
)
ckbytes
,
err
:=
GetBytes
(
ck
)
ckbytes
,
err
:=
GetBytes
(
ck
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorln
(
err
)
log
.
Errorln
(
err
)
}
}
// TODO: according design doc, need to save
u
uid to etcd in json format
// TODO: according design doc, need to save
U
uid to etcd in json format
// {\"
uuid\": [UUID], \"md5\", \"MD5 sum\", \"t
imestamp\": xxxx}
// {\"
Uuid\": [UUID], \"md5\", \"MD5 sum\", \"T
imestamp\": xxxx}
log
.
Infof
(
"parameter checkpoint %s"
,
ckbytes
)
log
.
Infof
(
"parameter checkpoint %s"
,
ckbytes
)
if
_
,
err
=
os
.
Stat
(
ck
.
u
uid
);
os
.
IsNotExist
(
err
)
{
if
_
,
err
=
os
.
Stat
(
ck
.
U
uid
);
os
.
IsNotExist
(
err
)
{
log
.
Info
(
"checkpoint not exists."
)
log
.
Info
(
"checkpoint not exists."
)
}
else
{
}
else
{
err
=
os
.
Remove
(
ck
.
u
uid
)
err
=
os
.
Remove
(
ck
.
U
uid
)
log
.
Infof
(
"remove %s"
,
ck
.
u
uid
)
log
.
Infof
(
"remove %s"
,
ck
.
U
uid
)
}
}
f
,
err
:=
os
.
Create
(
ck
.
u
uid
)
f
,
err
:=
os
.
Create
(
ck
.
U
uid
)
defer
f
.
Close
()
defer
f
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorln
(
err
)
log
.
Errorln
(
err
)
}
}
writer
:=
bufio
.
NewWriter
(
f
)
writer
:=
bufio
.
NewWriter
(
f
)
_
,
err
=
writer
.
Write
(
content
)
_
,
err
=
writer
.
Write
(
content
)
writer
.
Flush
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorln
(
err
)
log
.
Errorln
(
err
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录