Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
e68f2ed7
M
models
项目概览
PaddlePaddle
/
models
接近 2 年 前同步成功
通知
230
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看板
提交
e68f2ed7
编写于
9月 18, 2017
作者:
X
Xinghai Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add profile.sh script for multi-gpu profiling.
上级
67f9ef18
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
6 deletion
+48
-6
deep_speech_2/examples/librispeech/run_train.sh
deep_speech_2/examples/librispeech/run_train.sh
+1
-0
deep_speech_2/examples/tiny/run_train.sh
deep_speech_2/examples/tiny/run_train.sh
+1
-0
deep_speech_2/model_utils/model.py
deep_speech_2/model_utils/model.py
+13
-5
deep_speech_2/tools/profile.sh
deep_speech_2/tools/profile.sh
+30
-0
deep_speech_2/train.py
deep_speech_2/train.py
+3
-1
未找到文件。
deep_speech_2/examples/librispeech/run_train.sh
浏览文件 @
e68f2ed7
...
@@ -17,6 +17,7 @@ python -u train.py \
...
@@ -17,6 +17,7 @@ python -u train.py \
--learning_rate
=
5e-4
\
--learning_rate
=
5e-4
\
--max_duration
=
27.0
\
--max_duration
=
27.0
\
--min_duration
=
0.0
\
--min_duration
=
0.0
\
--test_off
=
False
\
--use_sortagrad
=
True
\
--use_sortagrad
=
True
\
--use_gru
=
False
\
--use_gru
=
False
\
--use_gpu
=
True
\
--use_gpu
=
True
\
...
...
deep_speech_2/examples/tiny/run_train.sh
浏览文件 @
e68f2ed7
...
@@ -17,6 +17,7 @@ python -u train.py \
...
@@ -17,6 +17,7 @@ python -u train.py \
--learning_rate
=
1e-5
\
--learning_rate
=
1e-5
\
--max_duration
=
27.0
\
--max_duration
=
27.0
\
--min_duration
=
0.0
\
--min_duration
=
0.0
\
--test_off
=
False
\
--use_sortagrad
=
True
\
--use_sortagrad
=
True
\
--use_gru
=
False
\
--use_gru
=
False
\
--use_gpu
=
True
\
--use_gpu
=
True
\
...
...
deep_speech_2/model_utils/model.py
浏览文件 @
e68f2ed7
...
@@ -54,7 +54,8 @@ class DeepSpeech2Model(object):
...
@@ -54,7 +54,8 @@ class DeepSpeech2Model(object):
num_passes
,
num_passes
,
output_model_dir
,
output_model_dir
,
is_local
=
True
,
is_local
=
True
,
num_iterations_print
=
100
):
num_iterations_print
=
100
,
test_off
=
False
):
"""Train the model.
"""Train the model.
:param train_batch_reader: Train data reader.
:param train_batch_reader: Train data reader.
...
@@ -77,6 +78,8 @@ class DeepSpeech2Model(object):
...
@@ -77,6 +78,8 @@ class DeepSpeech2Model(object):
:type is_local: bool
:type is_local: bool
:param output_model_dir: Directory for saving the model (every pass).
:param output_model_dir: Directory for saving the model (every pass).
:type output_model_dir: basestring
:type output_model_dir: basestring
:param test_off: Turn off testing.
:type test_off: bool
"""
"""
# prepare model output directory
# prepare model output directory
if
not
os
.
path
.
exists
(
output_model_dir
):
if
not
os
.
path
.
exists
(
output_model_dir
):
...
@@ -114,14 +117,19 @@ class DeepSpeech2Model(object):
...
@@ -114,14 +117,19 @@ class DeepSpeech2Model(object):
start_time
=
time
.
time
()
start_time
=
time
.
time
()
cost_sum
,
cost_counter
=
0.0
,
0
cost_sum
,
cost_counter
=
0.0
,
0
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
if
test_off
:
reader
=
dev_batch_reader
,
feeding
=
feeding_dict
)
print
(
"
\n
------- Time: %d sec, Pass: %d"
%
(
time
.
time
()
-
start_time
,
event
.
pass_id
))
else
:
result
=
trainer
.
test
(
reader
=
dev_batch_reader
,
feeding
=
feeding_dict
)
print
(
"
\n
------- Time: %d sec, Pass: %d, "
"ValidationCost: %s"
%
(
time
.
time
()
-
start_time
,
event
.
pass_id
,
0
))
output_model_path
=
os
.
path
.
join
(
output_model_path
=
os
.
path
.
join
(
output_model_dir
,
"params.pass-%d.tar.gz"
%
event
.
pass_id
)
output_model_dir
,
"params.pass-%d.tar.gz"
%
event
.
pass_id
)
with
gzip
.
open
(
output_model_path
,
'w'
)
as
f
:
with
gzip
.
open
(
output_model_path
,
'w'
)
as
f
:
self
.
_parameters
.
to_tar
(
f
)
self
.
_parameters
.
to_tar
(
f
)
print
(
"
\n
------- Time: %d sec, Pass: %d, ValidationCost: %s"
%
(
time
.
time
()
-
start_time
,
event
.
pass_id
,
result
.
cost
))
# run train
# run train
trainer
.
train
(
trainer
.
train
(
...
...
deep_speech_2/tools/profile.sh
0 → 100644
浏览文件 @
e68f2ed7
#! /usr/bin/env bash
BATCH_SIZE_PER_GPU
=
64
MIN_DURATION
=
6.0
MAX_DURATION
=
7.0
function
join_by
{
local
IFS
=
"
$1
"
;
shift
;
echo
"
$*
"
;
}
for
NUM_GPUS
in
16 8 4 2 1
do
DEVICES
=
$(
join_by ,
$(
seq
0
$((
$NUM_GPUS
-
1
))
))
BATCH_SIZE
=
$((
$BATCH_SIZE_PER_GPU
*
$NUM_GPUS
))
CUDA_VISIBLE_DEVICES
=
$DEVICES
\
python train.py
\
--batch_size
=
$BATCH_SIZE
\
--num_passes
=
1
\
--test_off
=
True
\
--trainer_count
=
$NUM_GPUS
\
--min_duration
=
$MIN_DURATION
\
--max_duration
=
$MAX_DURATION
>
tmp.log 2>&1
if
[
$?
-ne
0
]
;
then
exit
1
fi
cat
tmp.log |
grep
"Time"
|
awk
'{print "GPU Num: " "'
"
$NUM_GPUS
"
'" " Time: "$3}'
rm
tmp.log
done
deep_speech_2/train.py
浏览文件 @
e68f2ed7
...
@@ -25,6 +25,7 @@ add_arg('num_iter_print', int, 100, "Every # iterations for printing "
...
@@ -25,6 +25,7 @@ add_arg('num_iter_print', int, 100, "Every # iterations for printing "
add_arg
(
'learning_rate'
,
float
,
5e-4
,
"Learning rate."
)
add_arg
(
'learning_rate'
,
float
,
5e-4
,
"Learning rate."
)
add_arg
(
'max_duration'
,
float
,
27.0
,
"Longest audio duration allowed."
)
add_arg
(
'max_duration'
,
float
,
27.0
,
"Longest audio duration allowed."
)
add_arg
(
'min_duration'
,
float
,
0.0
,
"Shortest audio duration allowed."
)
add_arg
(
'min_duration'
,
float
,
0.0
,
"Shortest audio duration allowed."
)
add_arg
(
'test_off'
,
bool
,
False
,
"Turn off testing."
)
add_arg
(
'use_sortagrad'
,
bool
,
True
,
"Use SortaGrad or not."
)
add_arg
(
'use_sortagrad'
,
bool
,
True
,
"Use SortaGrad or not."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Use GPU or not."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Use GPU or not."
)
add_arg
(
'use_gru'
,
bool
,
False
,
"Use GRUs instead of simple RNNs."
)
add_arg
(
'use_gru'
,
bool
,
False
,
"Use GRUs instead of simple RNNs."
)
...
@@ -111,7 +112,8 @@ def train():
...
@@ -111,7 +112,8 @@ def train():
num_passes
=
args
.
num_passes
,
num_passes
=
args
.
num_passes
,
num_iterations_print
=
args
.
num_iter_print
,
num_iterations_print
=
args
.
num_iter_print
,
output_model_dir
=
args
.
output_model_dir
,
output_model_dir
=
args
.
output_model_dir
,
is_local
=
args
.
is_local
)
is_local
=
args
.
is_local
,
test_off
=
args
.
test_off
)
def
main
():
def
main
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录