Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
77e5641a
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看板
提交
77e5641a
编写于
4月 20, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tb logger
上级
16b8b982
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
16 deletion
+20
-16
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+6
-4
deepspeech/utils/checkpoint.py
deepspeech/utils/checkpoint.py
+3
-3
deepspeech/utils/layer_tools.py
deepspeech/utils/layer_tools.py
+11
-9
未找到文件。
deepspeech/exps/u2/model.py
浏览文件 @
77e5641a
...
...
@@ -88,10 +88,6 @@ class U2Trainer(Trainer):
losses_np
[
'ctc_loss'
]
=
float
(
ctc_loss
)
if
(
batch_index
+
1
)
%
train_conf
.
accum_grad
==
0
:
if
dist
.
get_rank
()
==
0
and
self
.
visualizer
:
losses_np_v
=
losses_np
.
copy
()
losses_np_v
.
update
({
"lr"
:
self
.
lr_scheduler
()})
self
.
visualizer
.
add_scalars
(
"step"
,
losses_np_v
,
self
.
iteration
)
self
.
optimizer
.
step
()
self
.
optimizer
.
clear_grad
()
self
.
lr_scheduler
.
step
()
...
...
@@ -107,6 +103,12 @@ class U2Trainer(Trainer):
for
k
,
v
in
losses_np
.
items
())
logger
.
info
(
msg
)
if
dist
.
get_rank
()
==
0
and
self
.
visualizer
:
losses_np_v
=
losses_np
.
copy
()
losses_np_v
.
update
({
"lr"
:
self
.
lr_scheduler
()})
self
.
visualizer
.
add_scalars
(
"step"
,
losses_np_v
,
self
.
iteration
-
1
)
def
train
(
self
):
"""The training process control by step."""
# !!!IMPORTANT!!!
...
...
deepspeech/utils/checkpoint.py
浏览文件 @
77e5641a
...
...
@@ -46,8 +46,8 @@ def _load_latest_checkpoint(checkpoint_dir: str) -> int:
return
iteration
def
_save_
checkpoint
(
checkpoint_dir
:
str
,
iteration
:
int
):
"""Save the iteration number of the latest model to be checkpoint
e
d.
def
_save_
record
(
checkpoint_dir
:
str
,
iteration
:
int
):
"""Save the iteration number of the latest model to be checkpoint
recor
d.
Args:
checkpoint_dir (str): the directory where checkpoint is saved.
iteration (int): the latest iteration number.
...
...
@@ -149,4 +149,4 @@ def save_parameters(checkpoint_dir: str,
fout
.
write
(
data
)
if
isinstance
(
tag_or_iteration
,
int
):
_save_
checkpoint
(
checkpoint_dir
,
tag_or_iteration
)
_save_
record
(
checkpoint_dir
,
tag_or_iteration
)
deepspeech/utils/layer_tools.py
浏览文件 @
77e5641a
...
...
@@ -21,6 +21,8 @@ __all__ = [
def
summary
(
layer
:
nn
.
Layer
,
print_func
=
print
):
if
print_func
is
None
:
return
num_params
=
num_elements
=
0
for
name
,
param
in
layer
.
state_dict
().
items
():
if
print_func
:
...
...
@@ -32,15 +34,6 @@ def summary(layer: nn.Layer, print_func=print):
print_func
(
f
"Total parameters:
{
num_params
}
,
{
num_elements
}
elements."
)
def
gradient_norm
(
layer
:
nn
.
Layer
):
grad_norm_dict
=
{}
for
name
,
param
in
layer
.
state_dict
().
items
():
if
param
.
trainable
:
grad
=
param
.
gradient
()
# return numpy.ndarray
grad_norm_dict
[
name
]
=
np
.
linalg
.
norm
(
grad
)
/
grad
.
size
return
grad_norm_dict
def
print_grads
(
model
,
print_func
=
print
):
if
print_func
is
None
:
return
...
...
@@ -64,6 +57,15 @@ def print_params(model, print_func=print):
print_func
(
f
"Total parameters:
{
num_params
}
,
{
total
}
elements."
)
def
gradient_norm
(
layer
:
nn
.
Layer
):
grad_norm_dict
=
{}
for
name
,
param
in
layer
.
state_dict
().
items
():
if
param
.
trainable
:
grad
=
param
.
gradient
()
# return numpy.ndarray
grad_norm_dict
[
name
]
=
np
.
linalg
.
norm
(
grad
)
/
grad
.
size
return
grad_norm_dict
def
recursively_remove_weight_norm
(
layer
:
nn
.
Layer
):
for
layer
in
layer
.
sublayers
():
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录