Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f5811ba4
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,发现更多精彩内容 >>
提交
f5811ba4
编写于
2月 05, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tiny fixes in profiling and training scripts
上级
cff2f954
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
15 deletion
+17
-15
fluid/DeepASR/data_utils/util.py
fluid/DeepASR/data_utils/util.py
+2
-0
fluid/DeepASR/model.py
fluid/DeepASR/model.py
+0
-2
fluid/DeepASR/profile.py
fluid/DeepASR/profile.py
+12
-10
fluid/DeepASR/train.py
fluid/DeepASR/train.py
+3
-3
未找到文件。
fluid/DeepASR/data_utils/util.py
浏览文件 @
f5811ba4
...
...
@@ -2,6 +2,8 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
numpy
as
np
def
to_lodtensor
(
data
,
place
):
"""convert tensor to lodtensor
...
...
fluid/DeepASR/model.py
浏览文件 @
f5811ba4
...
...
@@ -84,8 +84,6 @@ def _net_conf(feature, label, hidden_dim, proj_dim, stacked_num, class_num,
size
=
class_num
,
act
=
'softmax'
)
if
not
is_train
:
return
feature
,
prediction
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
avg_cost
=
fluid
.
layers
.
mean
(
x
=
cost
)
acc
=
fluid
.
layers
.
accuracy
(
input
=
prediction
,
label
=
label
)
...
...
fluid/DeepASR/profile.py
浏览文件 @
f5811ba4
...
...
@@ -71,13 +71,14 @@ def parse_args():
parser
.
add_argument
(
'--max_batch_num'
,
type
=
int
,
default
=
1
1
,
default
=
1
0
,
help
=
'Maximum number of batches for profiling. (default: %(default)d)'
)
parser
.
add_argument
(
'--
num_batch
_to_skip'
,
'--
first_batches
_to_skip'
,
type
=
int
,
default
=
1
,
help
=
'Number of batches to skip for profiling. (default: %(default)d)'
)
help
=
'Number of first batches to skip for profiling. '
'(default: %(default)d)'
)
parser
.
add_argument
(
'--print_train_acc'
,
action
=
'store_true'
,
...
...
@@ -103,14 +104,15 @@ def print_arguments(args):
def
profile
(
args
):
"""profile the training process"""
if
not
args
.
num_batch
_to_skip
<
args
.
max_batch_num
:
raise
ValueError
(
"arg '
num_batch
_to_skip' must be smaller than "
if
not
args
.
first_batches
_to_skip
<
args
.
max_batch_num
:
raise
ValueError
(
"arg '
first_batches
_to_skip' must be smaller than "
"'max_batch_num'."
)
if
not
args
.
num_batch_to_skip
>=
0
:
raise
ValueError
(
"arg 'num_batch_to_skip' must not be smaller than 0."
)
if
not
args
.
first_batches_to_skip
>=
0
:
raise
ValueError
(
"arg 'first_batches_to_skip' must not be smaller than 0."
)
prediction
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
args
.
hidden_dim
,
args
.
proj_dim
,
args
.
stacked_num
,
args
.
parallel
)
_
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
args
.
hidden_dim
,
args
.
proj_dim
,
args
.
stacked_num
,
args
.
parallel
)
adam_optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
args
.
learning_rate
)
adam_optimizer
.
minimize
(
avg_cost
)
...
...
@@ -135,7 +137,7 @@ def profile(args):
with
profiler
.
profiler
(
args
.
device
,
sorted_key
)
as
prof
:
frames_seen
,
start_time
=
0
,
0.0
for
batch_id
in
range
(
0
,
args
.
max_batch_num
):
if
args
.
num_batch
_to_skip
==
batch_id
:
if
args
.
first_batches
_to_skip
==
batch_id
:
profiler
.
reset_profiler
()
start_time
=
time
.
time
()
frames_seen
=
0
...
...
fluid/DeepASR/train.py
浏览文件 @
f5811ba4
...
...
@@ -92,8 +92,8 @@ def print_arguments(args):
def
train
(
args
):
"""train in loop."""
prediction
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
args
.
hidden_dim
,
args
.
proj_dim
,
args
.
stacked_num
,
args
.
parallel
)
_
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
args
.
hidden_dim
,
args
.
proj_dim
,
args
.
stacked_num
,
args
.
parallel
)
adam_optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
args
.
learning_rate
)
adam_optimizer
.
minimize
(
avg_cost
)
...
...
@@ -144,7 +144,7 @@ def train(args):
pass_end_time
=
time
.
time
()
time_consumed
=
pass_end_time
-
pass_start_time
# need to add test logic (kuke)
print
(
"
\n
Pass %d, time: %fs, test accuracy: 0.0f
\n
"
%
print
(
"
\n
Pass %d, time
consumed
: %fs, test accuracy: 0.0f
\n
"
%
(
pass_id
,
time_consumed
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录