Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
9c3cd3c7
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
207
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
You need to sign in or sign up before continuing.
提交
9c3cd3c7
编写于
5月 26, 2017
作者:
X
Xinghai Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update some parameters and comments.
上级
0babc5c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
16 deletion
+19
-16
train.py
train.py
+19
-16
未找到文件。
train.py
浏览文件 @
9c3cd3c7
...
...
@@ -26,6 +26,8 @@ parser.add_argument(
"--rnn_layer_size"
,
default
=
256
,
type
=
int
,
help
=
"RNN layer cell number."
)
parser
.
add_argument
(
"--use_gpu"
,
default
=
True
,
type
=
bool
,
help
=
"Use gpu or not."
)
parser
.
add_argument
(
"--use_sortagrad"
,
default
=
False
,
type
=
bool
,
help
=
"Use sortagrad or not."
)
parser
.
add_argument
(
"--trainer_count"
,
default
=
8
,
type
=
int
,
help
=
"Trainer number."
)
args
=
parser
.
parse_args
()
...
...
@@ -56,12 +58,9 @@ def train():
# create parameters and optimizer
parameters
=
paddle
.
parameters
.
create
(
cost
)
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
5e-5
,
gradient_clipping_threshold
=
5
,
regularization
=
paddle
.
optimizer
.
L2Regularization
(
rate
=
8e-4
))
learning_rate
=
5e-4
,
gradient_clipping_threshold
=
400
)
trainer
=
paddle
.
trainer
.
SGD
(
cost
=
cost
,
parameters
=
parameters
,
update_equation
=
optimizer
)
# create data readers
feeding
=
{
"audio_spectrogram"
:
0
,
...
...
@@ -70,13 +69,13 @@ def train():
train_batch_reader_with_sortagrad
=
audio_data_utils
.
padding_batch_reader
(
paddle
.
batch
(
audio_data_utils
.
reader_creator
(
manifest_path
=
"./libri.manifest.
dev
"
,
sort_by_duration
=
True
),
manifest_path
=
"./libri.manifest.
train
"
,
sort_by_duration
=
True
),
batch_size
=
args
.
batch_size
//
args
.
trainer
),
padding
=
[
-
1
,
1000
])
train_batch_reader_without_sortagrad
=
audio_data_utils
.
padding_batch_reader
(
paddle
.
batch
(
audio_data_utils
.
reader_creator
(
manifest_path
=
"./libri.manifest.
dev
"
,
manifest_path
=
"./libri.manifest.
train
"
,
sort_by_duration
=
False
,
shuffle
=
True
),
batch_size
=
args
.
batch_size
//
args
.
trainer
),
...
...
@@ -84,7 +83,7 @@ def train():
test_batch_reader
=
audio_data_utils
.
padding_batch_reader
(
paddle
.
batch
(
audio_data_utils
.
reader_creator
(
manifest_path
=
"./libri.manifest.
test
"
,
sort_by_duration
=
False
),
manifest_path
=
"./libri.manifest.
dev
"
,
sort_by_duration
=
False
),
batch_size
=
args
.
batch_size
//
args
.
trainer
),
padding
=
[
-
1
,
1000
])
...
...
@@ -92,27 +91,31 @@ def train():
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
10
==
0
:
print
"
Pass: %d, Batch: %d, TrainCost: %f, %s
"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
print
"
/nPass: %d, Batch: %d, TrainCost: %f
"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
)
else
:
sys
.
stdout
.
write
(
'.'
)
sys
.
stdout
.
flush
()
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
reader
=
test_batch_reader
,
feeding
=
feeding
)
print
"Pass: %d, Test
Metric: %s"
%
(
event
.
pass_id
,
result
.
metrics
)
print
"Pass: %d, Test
Cost: %s"
%
(
event
.
pass_id
,
result
.
cost
)
with
gzip
.
open
(
"params.tar.gz"
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
# run train
trainer
.
train
(
reader
=
train_batch_reader_with_sortagrad
,
event_handler
=
event_handler
,
num_passes
=
1
,
feeding
=
feeding
)
# first pass with sortagrad
if
args
.
use_sortagrad
:
trainer
.
train
(
reader
=
train_batch_reader_with_sortagrad
,
event_handler
=
event_handler
,
num_passes
=
1
,
feeding
=
feeding
)
args
.
num_passes
-=
1
# other passes without sortagrad
trainer
.
train
(
reader
=
train_batch_reader_without_sortagrad
,
event_handler
=
event_handler
,
num_passes
=
self
.
num_passes
-
1
,
num_passes
=
args
.
num_passes
,
feeding
=
feeding
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录