Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
1f217f0a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1f217f0a
编写于
6月 22, 2017
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"add c testing, python testing TODO"
上级
5128714c
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
36 addition
and
11 deletion
+36
-11
go/pserver/cclient/cclient.go
go/pserver/cclient/cclient.go
+1
-8
go/pserver/cclient/test/dump_optimizer_proto.py
go/pserver/cclient/test/dump_optimizer_proto.py
+13
-0
go/pserver/cclient/test/main.c
go/pserver/cclient/test/main.c
+12
-1
go/pserver/cclient/test/optimizer.pb.txt
go/pserver/cclient/test/optimizer.pb.txt
+0
-0
go/pserver/cclient/test/test_train.py
go/pserver/cclient/test/test_train.py
+2
-0
go/pserver/client_test.go
go/pserver/client_test.go
+6
-2
python/paddle/v2/optimizer.py
python/paddle/v2/optimizer.py
+2
-0
未找到文件。
go/pserver/cclient/cclient.go
浏览文件 @
1f217f0a
...
...
@@ -121,14 +121,7 @@ func paddle_begin_init_params(client C.paddle_pserver_client) C.int {
//export paddle_init_param
func
paddle_init_param
(
client
C
.
paddle_pserver_client
,
param
C
.
paddle_parameter
,
param_config
unsafe
.
Pointer
,
config_len
C
.
int
)
C
.
int
{
et
:=
pserver
.
ElementType
(
param
.
element_type
)
name
:=
C
.
GoString
(
param
.
name
)
pc
:=
pserver
.
ParameterWithConfig
{
Param
:
pserver
.
Parameter
{
Name
:
name
,
ElementType
:
et
,
Content
:
param
.
content
,
Length
:
para
.
content_len
},
Config
:
cArrayToSlice
(
param_config
,
int
(
config_len
)),
}
c
:=
get
(
client
)
err
:=
c
.
InitParam
(
pc
)
et
if
err
!=
nil
{
if
err
.
Error
()
==
pserver
.
AlreadyInitialized
{
...
...
go/pserver/cclient/test/dump_optimizer_proto.py
0 → 100644
浏览文件 @
1f217f0a
import
OptimizerConfig_pb2
as
pb
config
=
pb
.
OptimizerConfig
()
config
.
clip_norm
=
0.1
config
.
lr_policy
=
pb
.
OptimizerConfig
.
Const
config
.
optimizer
=
pb
.
OptimizerConfig
.
SGD
config
.
sgd
.
momentum
=
0.0
config
.
sgd
.
decay
=
0.0
config
.
sgd
.
nesterov
=
False
config
.
const_lr
.
learning_rate
=
0.1
s
=
config
.
SerializeToString
()
with
open
(
"optimizer.pb.txt"
,
'w'
)
as
f
:
f
.
write
(
s
)
go/pserver/cclient/test/main.c
浏览文件 @
1f217f0a
...
...
@@ -45,9 +45,20 @@ void getParams(paddle_pserver_client c) {
}
}
int
main
()
{
char
addr
[]
=
"localhost:3000"
;
paddle_pserver_client
c
=
paddle_new_pserver_client
(
addr
,
1
);
char
config_proto
[
1024
];
size_t
config_proto_len
=
0
;
ssize_t
nread
;
FILE
*
fp
=
fopen
(
"optimizer.pb.txt"
,
"r"
);
if
(
!
fp
)
{
fail
();
}
while
((
nread
=
getline
(
&
config_proto
,
&
config_proto_len
,
fp
))
!=
-
1
)
{
printf
(
"%s"
,
config_proto
);
}
fclose
(
fp
);
retry:
if
(
paddle_begin_init_params
(
c
))
{
paddle_parameter
param
;
...
...
@@ -59,7 +70,7 @@ retry:
param
.
name
=
name_a
;
param
.
content
=
content_a
;
param
.
content_len
=
2000
;
int
error
=
paddle_init_param
(
c
,
param
,
NULL
,
0
);
int
error
=
paddle_init_param
(
c
,
param
,
config_proto
,
config_proto_len
);
if
(
error
!=
0
)
{
goto
retry
;
}
...
...
go/pserver/cclient/test/optimizer.pb.txt
0 → 100644
浏览文件 @
1f217f0a
文件已添加
go/pserver/cclient/test/test_train.py
浏览文件 @
1f217f0a
...
...
@@ -22,6 +22,8 @@ def main():
# create optimizer
optimizer
=
paddle
.
optimizer
.
Momentum
(
momentum
=
0
)
#TODO(zhihong) : replace optimizer with new OptimizerConfig
trainer
=
paddle
.
trainer
.
SGD
(
cost
=
cost
,
parameters
=
parameters
,
update_equation
=
optimizer
,
...
...
go/pserver/client_test.go
浏览文件 @
1f217f0a
...
...
@@ -75,7 +75,9 @@ func TestClientFull(t *testing.T) {
var
p
pserver
.
Parameter
p
.
Name
=
"p_"
+
strconv
.
Itoa
(
i
)
p
.
ElementType
=
pserver
.
Float32
p
.
Content
=
make
([]
byte
,
(
i
+
1
)
*
100
)
ElementValue
:=
make
([]
byte
,
(
i
+
1
)
*
100
)
p
.
Content
=
&
ElementValue
[
0
]
p
.
Length
=
len
(
ElementValue
)
err
:=
c
.
InitParam
(
pserver
.
ParameterWithConfig
{
Param
:
p
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -92,7 +94,9 @@ func TestClientFull(t *testing.T) {
var
g
pserver
.
Gradient
g
.
Name
=
"p_"
+
strconv
.
Itoa
(
i
)
g
.
ElementType
=
pserver
.
Float32
g
.
Content
=
make
([]
byte
,
(
i
+
1
)
*
100
)
ElementValue
:=
make
([]
byte
,
(
i
+
1
)
*
100
)
g
.
Content
=
&
ElementValue
[
0
]
g
.
Length
=
len
(
ElementValue
)
grads
=
append
(
grads
,
g
)
}
...
...
python/paddle/v2/optimizer.py
浏览文件 @
1f217f0a
...
...
@@ -5,6 +5,8 @@ import paddle.trainer_config_helpers.optimizers as v1_optimizers
"""
Optimizers(update equation) for SGD method.
TODO(zhihong) : create new optimizer with proto config, add new optimizer here
TODO(yuyang18): Complete comments.
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录