Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
e61a6134
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
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看板
提交
e61a6134
编写于
4月 15, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
using np for speed perturb, remove some debug log of grad clip
上级
b355b67f
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
373 addition
and
53 deletion
+373
-53
.notebook/python_test.ipynb
.notebook/python_test.ipynb
+347
-36
deepspeech/frontend/audio.py
deepspeech/frontend/audio.py
+16
-11
deepspeech/io/dataset.py
deepspeech/io/dataset.py
+1
-0
deepspeech/training/gradclip.py
deepspeech/training/gradclip.py
+9
-6
未找到文件。
.notebook/python_test.ipynb
浏览文件 @
e61a6134
此差异已折叠。
点击以展开。
deepspeech/frontend/audio.py
浏览文件 @
e61a6134
...
@@ -22,7 +22,6 @@ import resampy
...
@@ -22,7 +22,6 @@ import resampy
from
scipy
import
signal
from
scipy
import
signal
import
random
import
random
import
copy
import
copy
import
sox
class
AudioSegment
(
object
):
class
AudioSegment
(
object
):
...
@@ -322,18 +321,24 @@ class AudioSegment(object):
...
@@ -322,18 +321,24 @@ class AudioSegment(object):
:type speed_rate: float
:type speed_rate: float
:raises ValueError: If speed_rate <= 0.0.
:raises ValueError: If speed_rate <= 0.0.
"""
"""
if
speed_rate
==
1.0
:
return
if
speed_rate
<=
0
:
if
speed_rate
<=
0
:
raise
ValueError
(
"speed_rate should be greater than zero."
)
raise
ValueError
(
"speed_rate should be greater than zero."
)
# old_length = self._samples.shape[0]
# new_length = int(old_length / speed_rate)
# numpy
# old_indices = np.arange(old_length)
old_length
=
self
.
_samples
.
shape
[
0
]
# new_indices = np.linspace(start=0, stop=old_length, num=new_length)
new_length
=
int
(
old_length
/
speed_rate
)
# self._samples = np.interp(new_indices, old_indices, self._samples)
old_indices
=
np
.
arange
(
old_length
)
tfm
=
sox
.
Transformer
()
new_indices
=
np
.
linspace
(
start
=
0
,
stop
=
old_length
,
num
=
new_length
)
tfm
.
set_globals
(
multithread
=
False
)
self
.
_samples
=
np
.
interp
(
new_indices
,
old_indices
,
self
.
_samples
)
tfm
.
speed
(
speed_rate
)
self
.
_samples
=
tfm
.
build_array
(
# sox, slow
input_array
=
self
.
_samples
,
sample_rate_in
=
self
.
_sample_rate
).
copy
()
# tfm = sox.Transformer()
# tfm.set_globals(multithread=False)
# tfm.speed(speed_rate)
# self._samples = tfm.build_array(
# input_array=self._samples, sample_rate_in=self._sample_rate).copy()
def
normalize
(
self
,
target_db
=-
20
,
max_gain_db
=
300.0
):
def
normalize
(
self
,
target_db
=-
20
,
max_gain_db
=
300.0
):
"""Normalize audio to be of the desired RMS value in decibels.
"""Normalize audio to be of the desired RMS value in decibels.
...
...
deepspeech/io/dataset.py
浏览文件 @
e61a6134
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
time
import
io
import
io
import
random
import
random
import
tarfile
import
tarfile
...
...
deepspeech/training/gradclip.py
浏览文件 @
e61a6134
...
@@ -43,11 +43,11 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
...
@@ -43,11 +43,11 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
merge_grad
=
layers
.
get_tensor_from_selected_rows
(
merge_grad
)
merge_grad
=
layers
.
get_tensor_from_selected_rows
(
merge_grad
)
square
=
layers
.
square
(
merge_grad
)
square
=
layers
.
square
(
merge_grad
)
sum_square
=
layers
.
reduce_sum
(
square
)
sum_square
=
layers
.
reduce_sum
(
square
)
logger
.
debug
(
f
"Grad Before Clip:
{
p
.
name
}
:
{
float
(
layers
.
sqrt
(
layers
.
reduce_sum
(
layers
.
square
(
merge_grad
)))
)
}
"
)
sum_square_list
.
append
(
sum_square
)
sum_square_list
.
append
(
sum_square
)
# debug log
# logger.debug(f"Grad Before Clip: {p.name}: {float(sum_square.sqrt()) }")
# all parameters have been filterd out
# all parameters have been filterd out
if
len
(
sum_square_list
)
==
0
:
if
len
(
sum_square_list
)
==
0
:
return
params_grads
return
params_grads
...
@@ -55,6 +55,7 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
...
@@ -55,6 +55,7 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
global_norm_var
=
layers
.
concat
(
sum_square_list
)
global_norm_var
=
layers
.
concat
(
sum_square_list
)
global_norm_var
=
layers
.
reduce_sum
(
global_norm_var
)
global_norm_var
=
layers
.
reduce_sum
(
global_norm_var
)
global_norm_var
=
layers
.
sqrt
(
global_norm_var
)
global_norm_var
=
layers
.
sqrt
(
global_norm_var
)
# debug log
logger
.
debug
(
f
"Grad Global Norm:
{
float
(
global_norm_var
)
}
!!!!"
)
logger
.
debug
(
f
"Grad Global Norm:
{
float
(
global_norm_var
)
}
!!!!"
)
max_global_norm
=
layers
.
fill_constant
(
max_global_norm
=
layers
.
fill_constant
(
shape
=
[
1
],
dtype
=
global_norm_var
.
dtype
,
value
=
self
.
clip_norm
)
shape
=
[
1
],
dtype
=
global_norm_var
.
dtype
,
value
=
self
.
clip_norm
)
...
@@ -68,9 +69,11 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
...
@@ -68,9 +69,11 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
params_and_grads
.
append
((
p
,
g
))
params_and_grads
.
append
((
p
,
g
))
continue
continue
new_grad
=
layers
.
elementwise_mul
(
x
=
g
,
y
=
clip_var
)
new_grad
=
layers
.
elementwise_mul
(
x
=
g
,
y
=
clip_var
)
logger
.
debug
(
f
"Grad After Clip:
{
p
.
name
}
:
{
float
(
layers
.
sqrt
(
layers
.
reduce_sum
(
layers
.
square
(
merge_grad
)))
)
}
"
)
params_and_grads
.
append
((
p
,
new_grad
))
params_and_grads
.
append
((
p
,
new_grad
))
# debug log
# logger.debug(
# f"Grad After Clip: {p.name}: {float(merge_grad.square().sum().sqrt())}"
# )
return
params_and_grads
return
params_and_grads
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录