Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
abd2f589
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看板
提交
abd2f589
编写于
4月 12, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs, add coverage, add scripts
上级
22fce191
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
73 addition
and
19 deletion
+73
-19
.travis/unittest.sh
.travis/unittest.sh
+20
-6
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+3
-6
deepspeech/models/deepspeech2.py
deepspeech/models/deepspeech2.py
+1
-0
deepspeech/models/u2.py
deepspeech/models/u2.py
+4
-2
deepspeech/training/trainer.py
deepspeech/training/trainer.py
+2
-3
examples/tiny/s1/local/export.sh
examples/tiny/s1/local/export.sh
+20
-0
examples/tiny/s1/local/test.sh
examples/tiny/s1/local/test.sh
+22
-0
examples/tiny/s1/local/train.sh
examples/tiny/s1/local/train.sh
+0
-2
requirements.txt
requirements.txt
+1
-0
未找到文件。
.travis/unittest.sh
浏览文件 @
abd2f589
#!/bin/bash
#!/bin/bash
abort
(){
echo
"Run unittest failed"
1>&2
echo
"Please check your code"
1>&2
exit
1
}
unittest
(){
unittest
(){
cd
$1
>
/dev/null
cd
$1
>
/dev/null
find
.
-path
./tools/venv
-prune
-false
-o
-name
'tests'
-type
d
-print0
|
\
find
.
-path
./tools/venv
-prune
-false
-o
-name
'tests'
-type
d
-print0
|
\
...
@@ -8,17 +17,22 @@ unittest(){
...
@@ -8,17 +17,22 @@ unittest(){
cd
-
>
/dev/null
cd
-
>
/dev/null
}
}
abort
(){
coverage
(){
echo
"Run unittest failed"
1>&2
cd
$1
>
/dev/null
echo
"Please check your code"
1>&2
find
.
-path
./tools/venv
-prune
-false
-o
-name
'tests'
-type
d
-print0
|
\
exit
1
xargs
-0
-I
{}
-n1
bash
-c
\
'python3 -m coverage run --branch {}'
python3
-m
coverage report
-m
python3
-m
coverage html
cd
-
>
/dev/null
}
}
trap
'abort'
0
trap
'abort'
0
set
-e
set
-e
source
tools/venv/bin/activate
source
tools/venv/bin/activate
pip3
install
pytest
#pip3 install pytest
unittest
.
#unittest .
coverage
.
trap
: 0
trap
: 0
deepspeech/exps/u2/model.py
浏览文件 @
abd2f589
...
@@ -74,7 +74,7 @@ class U2Trainer(Trainer):
...
@@ -74,7 +74,7 @@ class U2Trainer(Trainer):
def
__init__
(
self
,
config
,
args
):
def
__init__
(
self
,
config
,
args
):
super
().
__init__
(
config
,
args
)
super
().
__init__
(
config
,
args
)
def
train_batch
(
self
,
batch_data
):
def
train_batch
(
self
,
batch_data
,
msg
):
train_conf
=
self
.
config
.
training
train_conf
=
self
.
config
.
training
self
.
model
.
train
()
self
.
model
.
train
()
...
@@ -93,12 +93,9 @@ class U2Trainer(Trainer):
...
@@ -93,12 +93,9 @@ class U2Trainer(Trainer):
'train_att_loss'
:
float
(
attention_loss
),
'train_att_loss'
:
float
(
attention_loss
),
'train_ctc_loss'
:
float
(
ctc_loss
),
'train_ctc_loss'
:
float
(
ctc_loss
),
}
}
msg
=
"Train: Rank: {}, "
.
format
(
dist
.
get_rank
())
msg
+=
"epoch: {}, "
.
format
(
self
.
epoch
)
msg
+=
"step: {}, "
.
format
(
self
.
iteration
)
msg
+=
"time: {:>.3f}s, "
.
format
(
iteration_time
)
msg
+=
"time: {:>.3f}s, "
.
format
(
iteration_time
)
msg
+=
f
"batch size:
{
self
.
config
.
data
.
batch_size
}
, "
msg
+=
"batch size: {}, "
.
format
(
self
.
config
.
data
.
batch_size
)
msg
+=
f
"accum:
{
train_config
.
accum_grad
}
, "
msg
+=
"accum: {}, "
.
format
(
train_conf
.
accum_grad
)
msg
+=
', '
.
join
(
'{}: {:>.6f}'
.
format
(
k
,
v
)
msg
+=
', '
.
join
(
'{}: {:>.6f}'
.
format
(
k
,
v
)
for
k
,
v
in
losses_np
.
items
())
for
k
,
v
in
losses_np
.
items
())
if
self
.
iteration
%
train_conf
.
log_interval
==
0
:
if
self
.
iteration
%
train_conf
.
log_interval
==
0
:
...
...
deepspeech/models/deepspeech2.py
浏览文件 @
abd2f589
...
@@ -16,6 +16,7 @@ import logging
...
@@ -16,6 +16,7 @@ import logging
from
typing
import
Optional
from
typing
import
Optional
from
yacs.config
import
CfgNode
from
yacs.config
import
CfgNode
import
paddle
from
paddle
import
nn
from
paddle
import
nn
from
deepspeech.modules.conv
import
ConvStack
from
deepspeech.modules.conv
import
ConvStack
...
...
deepspeech/models/u2.py
浏览文件 @
abd2f589
...
@@ -761,8 +761,10 @@ class U2Model(U2BaseModel):
...
@@ -761,8 +761,10 @@ class U2Model(U2BaseModel):
Returns:
Returns:
DeepSpeech2Model: The model built from pretrained result.
DeepSpeech2Model: The model built from pretrained result.
"""
"""
config
.
input_dim
=
self
.
dataset
.
feature_size
config
.
defrost
()
config
.
output_dim
=
self
.
dataset
.
vocab_size
config
.
input_dim
=
dataset
.
feature_size
config
.
output_dim
=
dataset
.
vocab_size
config
.
freeze
()
model
=
cls
.
from_config
(
config
)
model
=
cls
.
from_config
(
config
)
if
checkpoint_path
:
if
checkpoint_path
:
...
...
deepspeech/training/trainer.py
浏览文件 @
abd2f589
...
@@ -181,13 +181,12 @@ class Trainer():
...
@@ -181,13 +181,12 @@ class Trainer():
msg
+=
"epoch: {}, "
.
format
(
self
.
epoch
)
msg
+=
"epoch: {}, "
.
format
(
self
.
epoch
)
msg
+=
"step: {}, "
.
format
(
self
.
iteration
)
msg
+=
"step: {}, "
.
format
(
self
.
iteration
)
msg
+=
"dataloader time: {:>.3f}s, "
.
format
(
dataload_time
)
msg
+=
"dataloader time: {:>.3f}s, "
.
format
(
dataload_time
)
self
.
logger
.
info
(
msg
)
self
.
iteration
+=
1
self
.
iteration
+=
1
self
.
train_batch
(
batch
)
self
.
train_batch
(
batch
,
msg
)
data_start_time
=
time
.
time
()
data_start_time
=
time
.
time
()
except
Exception
as
e
:
except
Exception
as
e
:
self
.
logger
.
error
(
e
)
self
.
logger
.
error
(
e
)
pass
raise
e
self
.
valid
()
self
.
valid
()
self
.
save
()
self
.
save
()
...
...
examples/tiny/s1/local/export.sh
0 → 100644
浏览文件 @
abd2f589
#! /usr/bin/env bash
if
[
$#
!=
2
]
;
then
echo
"usage: export ckpt_path jit_model_path"
exit
-1
fi
python3
-u
${
BIN_DIR
}
/export.py
\
--config
conf/conformer.yaml
\
--checkpoint_path
${
1
}
\
--export_path
${
2
}
if
[
$?
-ne
0
]
;
then
echo
"Failed in evaluation!"
exit
1
fi
exit
0
examples/tiny/s1/local/test.sh
0 → 100644
浏览文件 @
abd2f589
#! /usr/bin/env bash
# download language model
bash
local
/download_lm_en.sh
if
[
$?
-ne
0
]
;
then
exit
1
fi
CUDA_VISIBLE_DEVICES
=
0
\
python3
-u
${
BIN_DIR
}
/test.py
\
--device
'gpu'
\
--nproc
1
\
--config
conf/conformer.yaml
\
--output
ckpt
if
[
$?
-ne
0
]
;
then
echo
"Failed in evaluation!"
exit
1
fi
exit
0
examples/tiny/s1/local/train.sh
浏览文件 @
abd2f589
#! /usr/bin/env bash
#! /usr/bin/env bash
export
FLAGS_sync_nccl_allreduce
=
0
CUDA_VISIBLE_DEVICES
=
0
\
CUDA_VISIBLE_DEVICES
=
0
\
python3
-u
${
BIN_DIR
}
/train.py
\
python3
-u
${
BIN_DIR
}
/train.py
\
--device
'gpu'
\
--device
'gpu'
\
...
...
requirements.txt
浏览文件 @
abd2f589
coverage
pre-commit
pre-commit
python_speech_features
python_speech_features
resampy
==0.2.2
resampy
==0.2.2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录