Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
65e66637
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看板
提交
65e66637
编写于
9月 09, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add timer info
上级
b8601c75
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
45 addition
and
45 deletion
+45
-45
deepspeech/training/gradclip.py
deepspeech/training/gradclip.py
+5
-7
deepspeech/training/timer.py
deepspeech/training/timer.py
+3
-2
deepspeech/training/trainer.py
deepspeech/training/trainer.py
+37
-36
未找到文件。
deepspeech/training/gradclip.py
浏览文件 @
65e66637
...
@@ -48,7 +48,6 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
...
@@ -48,7 +48,6 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
sum_square_list
.
append
(
sum_square
)
sum_square_list
.
append
(
sum_square
)
# debug log
# debug log
if
i
<
10
:
logger
.
debug
(
logger
.
debug
(
f
"Grad Before Clip:
{
p
.
name
}
:
{
float
(
sum_square
.
sqrt
())
}
"
)
f
"Grad Before Clip:
{
p
.
name
}
:
{
float
(
sum_square
.
sqrt
())
}
"
)
...
@@ -77,7 +76,6 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
...
@@ -77,7 +76,6 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
params_and_grads
.
append
((
p
,
new_grad
))
params_and_grads
.
append
((
p
,
new_grad
))
# debug log
# debug log
if
i
<
10
:
logger
.
debug
(
logger
.
debug
(
f
"Grad After Clip:
{
p
.
name
}
:
{
float
(
new_grad
.
square
().
sum
().
sqrt
())
}
"
f
"Grad After Clip:
{
p
.
name
}
:
{
float
(
new_grad
.
square
().
sum
().
sqrt
())
}
"
)
)
...
...
deepspeech/training/timer.py
浏览文件 @
65e66637
...
@@ -27,7 +27,7 @@ class Timer():
...
@@ -27,7 +27,7 @@ class Timer():
do some thing
do some thing
"""
"""
def
__init__
(
self
,
message
):
def
__init__
(
self
,
message
=
None
):
self
.
message
=
message
self
.
message
=
message
def
duration
(
self
)
->
str
:
def
duration
(
self
)
->
str
:
...
@@ -40,6 +40,7 @@ class Timer():
...
@@ -40,6 +40,7 @@ class Timer():
return
self
return
self
def
__exit__
(
self
,
type
,
value
,
traceback
):
def
__exit__
(
self
,
type
,
value
,
traceback
):
if
self
.
message
:
logger
.
info
(
self
.
message
.
format
(
self
.
duration
()))
logger
.
info
(
self
.
message
.
format
(
self
.
duration
()))
def
__call__
(
self
)
->
float
:
def
__call__
(
self
)
->
float
:
...
...
deepspeech/training/trainer.py
浏览文件 @
65e66637
...
@@ -185,7 +185,6 @@ class Trainer():
...
@@ -185,7 +185,6 @@ class Trainer():
def
train
(
self
):
def
train
(
self
):
"""The training process control by epoch."""
"""The training process control by epoch."""
with
Timer
(
"Load/Init Model: {}"
):
from_scratch
=
self
.
resume_or_scratch
()
from_scratch
=
self
.
resume_or_scratch
()
if
from_scratch
:
if
from_scratch
:
# save init model, i.e. 0 epoch
# save init model, i.e. 0 epoch
...
@@ -196,6 +195,7 @@ class Trainer():
...
@@ -196,6 +195,7 @@ class Trainer():
logger
.
info
(
f
"Train Total Examples:
{
len
(
self
.
train_loader
.
dataset
)
}
"
)
logger
.
info
(
f
"Train Total Examples:
{
len
(
self
.
train_loader
.
dataset
)
}
"
)
while
self
.
epoch
<
self
.
config
.
training
.
n_epoch
:
while
self
.
epoch
<
self
.
config
.
training
.
n_epoch
:
with
Timer
(
"Epoch-Train Time Cost: {}"
):
self
.
model
.
train
()
self
.
model
.
train
()
try
:
try
:
data_start_time
=
time
.
time
()
data_start_time
=
time
.
time
()
...
@@ -214,6 +214,7 @@ class Trainer():
...
@@ -214,6 +214,7 @@ class Trainer():
logger
.
error
(
e
)
logger
.
error
(
e
)
raise
e
raise
e
with
Timer
(
"Eval Time Cost: {}"
):
total_loss
,
num_seen_utts
=
self
.
valid
()
total_loss
,
num_seen_utts
=
self
.
valid
()
if
dist
.
get_world_size
()
>
1
:
if
dist
.
get_world_size
()
>
1
:
num_seen_utts
=
paddle
.
to_tensor
(
num_seen_utts
)
num_seen_utts
=
paddle
.
to_tensor
(
num_seen_utts
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录