Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c8067ed5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c8067ed5
编写于
2月 16, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rearrange event.
上级
059a162b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
17 deletion
+20
-17
demo/mnist/api_train_v2.py
demo/mnist/api_train_v2.py
+2
-2
python/paddle/v2/__init__.py
python/paddle/v2/__init__.py
+2
-1
python/paddle/v2/event.py
python/paddle/v2/event.py
+12
-0
python/paddle/v2/trainer.py
python/paddle/v2/trainer.py
+4
-14
未找到文件。
demo/mnist/api_train_v2.py
浏览文件 @
c8067ed5
...
...
@@ -36,7 +36,7 @@ def main():
learning_rate
=
0.01
,
learning_method
=
AdamOptimizer
())
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
trainer
.
EndIteration
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
para
=
parameters
[
'___fc_layer_2__.w0'
]
print
"Pass %d, Batch %d, Cost %f, Weight Mean Of Fc 2 is %f"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
para
.
mean
())
...
...
@@ -44,7 +44,7 @@ def main():
else
:
pass
trainer
=
paddle
.
trainer
.
SGD
Trainer
(
update_equation
=
adam_optimizer
)
trainer
=
paddle
.
trainer
.
SGD
(
update_equation
=
adam_optimizer
)
trainer
.
train
(
train_data_reader
=
train_reader
,
topology
=
model_config
,
...
...
python/paddle/v2/__init__.py
浏览文件 @
c8067ed5
...
...
@@ -15,8 +15,9 @@ import optimizer
import
parameters
import
py_paddle.swig_paddle
as
api
import
trainer
import
event
__all__
=
[
'optimizer'
,
'parameters'
,
'init'
,
'trainer'
]
__all__
=
[
'optimizer'
,
'parameters'
,
'init'
,
'trainer'
,
'event'
]
def
init
(
**
kwargs
):
...
...
python/paddle/v2/event.py
0 → 100644
浏览文件 @
c8067ed5
__all__
=
[
'EndIteration'
]
class
EndIteration
(
object
):
"""
Event On One Batch Training Complete.
"""
def
__init__
(
self
,
pass_id
,
batch_id
,
cost
):
self
.
pass_id
=
pass_id
self
.
batch_id
=
batch_id
self
.
cost
=
cost
python/paddle/v2/trainer.py
浏览文件 @
c8067ed5
...
...
@@ -6,19 +6,9 @@ from py_paddle import DataProviderConverter
from
paddle.proto.ModelConfig_pb2
import
ModelConfig
from
.
import
optimizer
as
v2_optimizer
from
.
import
parameters
as
v2_parameters
from
.
import
event
as
v2_event
__all__
=
[
'ITrainer'
,
'SGDTrainer'
,
'EndIteration'
]
class
EndIteration
(
object
):
"""
Event On One Batch Training Complete.
"""
def
__init__
(
self
,
pass_id
,
batch_id
,
cost
):
self
.
pass_id
=
pass_id
self
.
batch_id
=
batch_id
self
.
cost
=
cost
__all__
=
[
'ITrainer'
,
'SGD'
]
def
default_event_handler
(
event
):
...
...
@@ -35,7 +25,7 @@ class ITrainer(object):
raise
NotImplementedError
()
class
SGD
Trainer
(
ITrainer
):
class
SGD
(
ITrainer
):
def
__init__
(
self
,
update_equation
):
"""
Simple SGD Trainer.
...
...
@@ -110,7 +100,7 @@ class SGDTrainer(ITrainer):
cost
=
cost_vec
.
sum
()
/
len
(
data_batch
)
updater
.
finishBatch
(
cost
)
event_handler
(
EndIteration
(
v2_event
.
EndIteration
(
pass_id
=
pass_id
,
batch_id
=
batch_id
,
cost
=
cost
))
updater
.
finishPass
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录