Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8e0d1d8b
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看板
提交
8e0d1d8b
编写于
2月 13, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Complete update equation.
上级
e13d9c74
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
7 deletion
+28
-7
demo/mnist/api_train_v2.py
demo/mnist/api_train_v2.py
+1
-1
python/paddle/v2/trainer.py
python/paddle/v2/trainer.py
+27
-6
未找到文件。
demo/mnist/api_train_v2.py
浏览文件 @
8e0d1d8b
...
@@ -49,7 +49,7 @@ def main():
...
@@ -49,7 +49,7 @@ def main():
:return:
:return:
"""
"""
mu
=
0.09
mu
=
0.09
e
=
0.0001
e
=
0.000
0
1
vel_t
=
mu
*
vel_t_1
-
e
*
g
vel_t
=
mu
*
vel_t_1
-
e
*
g
...
...
python/paddle/v2/trainer.py
浏览文件 @
8e0d1d8b
...
@@ -25,7 +25,7 @@ class CompleteTrainOneBatch(BaseEvent):
...
@@ -25,7 +25,7 @@ class CompleteTrainOneBatch(BaseEvent):
self
.
pass_id
=
pass_id
self
.
pass_id
=
pass_id
self
.
batch_id
=
batch_id
self
.
batch_id
=
batch_id
self
.
cost
=
cost
self
.
cost
=
cost
self
.
paramters
=
parameters
self
.
param
e
ters
=
parameters
def
default_event_handler
(
event
):
def
default_event_handler
(
event
):
...
@@ -44,6 +44,17 @@ class ITrainer(object):
...
@@ -44,6 +44,17 @@ class ITrainer(object):
class
LazyParameterPool
(
v2_parameters
.
IParameterPool
):
class
LazyParameterPool
(
v2_parameters
.
IParameterPool
):
"""
"""
Lazy Parameter Pool stores a reference to GradientMachine. User could invoke
`get_parameter` if needed, but the operation is lazy. It means the parameter
will only fetched from GPU or Parameter Server if `get_parameter` is
invoked. Also, set flag = writable will make a extra host2device copy after
reading/modifying parameter.
This class is not exposed to User. User should treat this class as a normal
IParameterPool.
See IParameterPool for usage documentation.
:type __gradient_machine__: api.GradientMachine
:type __gradient_machine__: api.GradientMachine
"""
"""
...
@@ -130,12 +141,22 @@ class CustomizeUpdateEquation(object):
...
@@ -130,12 +141,22 @@ class CustomizeUpdateEquation(object):
shape
)
shape
)
g
=
param
.
getBuf
(
api
.
PARAMETER_GRADIENT
).
toNumpyArrayInplace
(
g
=
param
.
getBuf
(
api
.
PARAMETER_GRADIENT
).
toNumpyArrayInplace
(
).
reshape
(
shape
)
).
reshape
(
shape
)
args
=
[
v
,
g
]
for
arg
in
self
.
local_params
[
conf
.
name
]:
args
.
append
(
arg
)
self
.
__callback__
(
*
args
)
else
:
else
:
raise
NotImplementedError
()
v
=
param
.
getBuf
(
api
.
PARAMETER_VALUE
).
copyToNumpyArray
().
reshape
(
shape
)
g
=
param
.
getBuf
(
api
.
PARAMETER_GRADIENT
).
copyToNumpyArray
().
reshape
(
shape
)
args
=
[
v
,
g
]
for
arg
in
self
.
local_params
[
conf
.
name
]:
args
.
append
(
arg
)
self
.
__callback__
(
*
args
)
if
api
.
isUsingGpu
():
param
.
getBuf
(
api
.
PARAMETER_VALUE
).
copyFromNumpyArray
(
v
.
flatten
(
).
astype
(
'float32'
))
# discard gradient changed.
class
SGDTrainer
(
ITrainer
):
class
SGDTrainer
(
ITrainer
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录