Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f49029cc
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f49029cc
编写于
10月 09, 2017
作者:
C
Cao Ying
提交者:
GitHub
10月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #356 from lcy-seso/fix_print_gradient_in_GNR
fix a bug in printing parameter gradients during training for GNR.
上级
cb7e720e
2962acaa
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
17 deletion
+18
-17
globally_normalized_reader/basic_modules.py
globally_normalized_reader/basic_modules.py
+0
-1
globally_normalized_reader/beam_decoding.py
globally_normalized_reader/beam_decoding.py
+0
-1
globally_normalized_reader/config.py
globally_normalized_reader/config.py
+5
-5
globally_normalized_reader/featurize.py
globally_normalized_reader/featurize.py
+1
-1
globally_normalized_reader/infer.py
globally_normalized_reader/infer.py
+0
-1
globally_normalized_reader/train.py
globally_normalized_reader/train.py
+12
-8
未找到文件。
globally_normalized_reader/basic_modules.py
浏览文件 @
f49029cc
#!/usr/bin/env python
#coding=utf-8
import
collections
...
...
globally_normalized_reader/beam_decoding.py
浏览文件 @
f49029cc
#!/usr/bin/env python
#coding=utf-8
import
numpy
as
np
...
...
globally_normalized_reader/config.py
浏览文件 @
f49029cc
#!/usr/bin/env python
#coding=utf-8
__all__
=
[
"ModelConfig"
,
"TrainerConfig"
]
...
...
@@ -36,11 +35,12 @@ class TrainerConfig(object):
epochs
=
20
# for debug print, if set to 0, no information will be printed.
# This parameter is for debug printing.
# If it set to 0, no information will be printed.
show_parameter_status_period
=
0
checkpoint_period
=
100
log_period
=
1
log_period
=
5
#
this is used to resume training, this path can set to previously
# trained model.
#
This parameter is used to resume training.
#
This path can be set to a previously
trained model.
init_model_path
=
None
globally_normalized_reader/featurize.py
浏览文件 @
f49029cc
#
-*- coding: utf-8 -*-
#
coding=utf-8
"""
Convert the raw json data into training and validation examples.
"""
...
...
globally_normalized_reader/infer.py
浏览文件 @
f49029cc
#!/usr/bin/env python
#coding=utf-8
import
os
...
...
globally_normalized_reader/train.py
浏览文件 @
f49029cc
#!/usr/bin/env python
#coding=utf-8
from
__future__
import
print_function
...
...
@@ -147,22 +146,27 @@ def build_event_handler(config, parameters, trainer):
# End batch and end pass event handler
def
event_handler
(
event
):
"""The event handler."""
"""
To print the statistical information of gradients of any learnable
parameter, the event: EndForwardBackward rather than EndIteration
should be handled. For the reason that parameter gradients will be
reset to zeros when EndIteration event happens in GPU training.
"""
if
config
.
show_parameter_status_period
and
\
isinstance
(
event
,
paddle
.
event
.
EndForwardBackward
):
if
not
event
.
batch_id
%
config
.
show_parameter_status_period
:
show_parameter_status
(
parameters
)
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
and
\
(
not
event
.
batch_id
%
config
.
checkpoint_period
):
if
event
.
batch_id
and
not
event
.
batch_id
%
config
.
checkpoint_period
:
save_path
=
os
.
path
.
join
(
config
.
save_dir
,
"checkpoint_param.latest.tar.gz"
)
save_model
(
save_path
,
parameters
)
if
event
.
batch_id
and
not
event
.
batch_id
%
config
.
log_period
:
if
not
event
.
batch_id
%
config
.
log_period
:
logger
.
info
(
"Pass %d, Batch %d, Cost %f"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
))
if
config
.
show_parameter_status_period
and
event
.
batch_id
and
\
not
(
event
.
batch_id
%
config
.
show_parameter_status_period
):
show_parameter_status
(
parameters
)
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
save_path
=
os
.
path
.
join
(
config
.
save_dir
,
"pass_%05d.tar.gz"
%
event
.
pass_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录