Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
d5ccd221
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d5ccd221
编写于
5月 06, 2019
作者:
K
Kaipeng Deng
提交者:
GitHub
5月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix video get learning_rate error (#2172)
* fix video get learning_rate error * refine comment
上级
9952b253
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
10 deletion
+25
-10
PaddleCV/video/tools/train_utils.py
PaddleCV/video/tools/train_utils.py
+25
-10
未找到文件。
PaddleCV/video/tools/train_utils.py
浏览文件 @
d5ccd221
...
...
@@ -9,6 +9,29 @@ import shutil
logger
=
logging
.
getLogger
(
__name__
)
def
log_lr_and_step
():
try
:
# In optimizers, if learning_rate is set as constant, lr_var
# name is 'learning_rate_0', and iteration counter is not
# recorded. If learning_rate is set as decayed values from
# learning_rate_scheduler, lr_var name is 'learning_rate',
# and iteration counter is recorded with name '@LR_DECAY_COUNTER@',
# better impliment is required here
lr_var
=
fluid
.
global_scope
().
find_var
(
"learning_rate"
)
if
not
lr_var
:
lr_var
=
fluid
.
global_scope
().
find_var
(
"learning_rate_0"
)
lr
=
np
.
array
(
lr_var
.
get_tensor
())
lr_count
=
'[-]'
lr_count_var
=
fluid
.
global_scope
().
find_var
(
"@LR_DECAY_COUNTER@"
)
if
lr_count_var
:
lr_count
=
np
.
array
(
lr_count_var
.
get_tensor
())
logger
.
info
(
"------- learning rate {}, learning rate counter {} -----"
.
format
(
np
.
array
(
lr
),
np
.
array
(
lr_count
)))
except
:
logger
.
warn
(
"Unable to get learning_rate and LR_DECAY_COUNTER."
)
def
test_without_pyreader
(
test_exe
,
test_reader
,
test_feeder
,
...
...
@@ -61,11 +84,7 @@ def train_without_pyreader(exe, train_prog, train_exe, train_reader, train_feede
save_model_name
=
'model'
,
test_exe
=
None
,
test_reader
=
None
,
\
test_feeder
=
None
,
test_fetch_list
=
None
,
test_metrics
=
None
):
for
epoch
in
range
(
epochs
):
lr
=
fluid
.
global_scope
().
find_var
(
"learning_rate"
).
get_tensor
()
lr_count
=
fluid
.
global_scope
().
find_var
(
"@LR_DECAY_COUNTER@"
).
get_tensor
()
logger
.
info
(
"------- learning rate {}, learning rate counter {} -----"
.
format
(
np
.
array
(
lr
),
np
.
array
(
lr_count
)))
log_lr_and_step
()
epoch_periods
=
[]
for
train_iter
,
data
in
enumerate
(
train_reader
()):
cur_time
=
time
.
time
()
...
...
@@ -101,11 +120,7 @@ def train_with_pyreader(exe, train_prog, train_exe, train_pyreader, \
if
not
train_pyreader
:
logger
.
error
(
"[TRAIN] get pyreader failed."
)
for
epoch
in
range
(
epochs
):
lr
=
fluid
.
global_scope
().
find_var
(
"learning_rate"
).
get_tensor
()
lr_count
=
fluid
.
global_scope
().
find_var
(
"@LR_DECAY_COUNTER@"
).
get_tensor
()
logger
.
info
(
"------- learning rate {}, learning rate counter {} -----"
.
format
(
np
.
array
(
lr
),
np
.
array
(
lr_count
)))
log_lr_and_step
()
train_pyreader
.
start
()
train_metrics
.
reset
()
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录