Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
7473ec05
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7473ec05
编写于
3月 26, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
差异文件
Resolve conficts in decoder
上级
193c7e2d
745591ac
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
13 deletion
+49
-13
fluid/DeepASR/infer_by_ckpt.py
fluid/DeepASR/infer_by_ckpt.py
+12
-1
fluid/DeepASR/model_utils/model.py
fluid/DeepASR/model_utils/model.py
+13
-10
fluid/DeepASR/tools/profile.py
fluid/DeepASR/tools/profile.py
+12
-1
fluid/DeepASR/train.py
fluid/DeepASR/train.py
+12
-1
未找到文件。
fluid/DeepASR/infer_by_ckpt.py
浏览文件 @
7473ec05
...
...
@@ -32,6 +32,11 @@ def parse_args():
default
=
1
,
help
=
'The minimum sequence number of a batch data. '
'(default: %(default)d)'
)
parser
.
add_argument
(
'--frame_dim'
,
type
=
int
,
default
=
120
*
11
,
help
=
'Frame dimension of feature data. (default: %(default)d)'
)
parser
.
add_argument
(
'--stacked_num'
,
type
=
int
,
...
...
@@ -47,6 +52,11 @@ def parse_args():
type
=
int
,
default
=
1024
,
help
=
'Hidden size of lstmp unit. (default: %(default)d)'
)
parser
.
add_argument
(
'--class_num'
,
type
=
int
,
default
=
1749
,
help
=
'Number of classes in label. (default: %(default)d)'
)
parser
.
add_argument
(
'--learning_rate'
,
type
=
float
,
...
...
@@ -114,10 +124,11 @@ def infer_from_ckpt(args):
raise
IOError
(
"Invalid checkpoint!"
)
prediction
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
frame_dim
=
args
.
frame_dim
,
hidden_dim
=
args
.
hidden_dim
,
proj_dim
=
args
.
proj_dim
,
stacked_num
=
args
.
stacked_num
,
class_num
=
1749
,
class_num
=
args
.
class_num
,
parallel
=
args
.
parallel
)
infer_program
=
fluid
.
default_main_program
().
clone
()
...
...
fluid/DeepASR/model_utils/model.py
浏览文件 @
7473ec05
...
...
@@ -6,7 +6,8 @@ import paddle.v2 as paddle
import
paddle.fluid
as
fluid
def
stacked_lstmp_model
(
hidden_dim
,
def
stacked_lstmp_model
(
frame_dim
,
hidden_dim
,
proj_dim
,
stacked_num
,
class_num
,
...
...
@@ -20,12 +21,13 @@ def stacked_lstmp_model(hidden_dim,
label data respectively. And in inference, only `feature` is needed.
Args:
hidden_dim(int): The hidden state's dimension of the LSTMP layer.
proj_dim(int): The projection size of the LSTMP layer.
stacked_num(int): The number of stacked LSTMP layers.
parallel(bool): Run in parallel or not, default `False`.
is_train(bool): Run in training phase or not, default `True`.
class_dim(int): The number of output classes.
frame_dim(int): The frame dimension of feature data.
hidden_dim(int): The hidden state's dimension of the LSTMP layer.
proj_dim(int): The projection size of the LSTMP layer.
stacked_num(int): The number of stacked LSTMP layers.
parallel(bool): Run in parallel or not, default `False`.
is_train(bool): Run in training phase or not, default `True`.
class_dim(int): The number of output classes.
"""
# network configuration
...
...
@@ -78,7 +80,7 @@ def stacked_lstmp_model(hidden_dim,
# data feeder
feature
=
fluid
.
layers
.
data
(
name
=
"feature"
,
shape
=
[
-
1
,
120
*
11
],
dtype
=
"float32"
,
lod_level
=
1
)
name
=
"feature"
,
shape
=
[
-
1
,
frame_dim
],
dtype
=
"float32"
,
lod_level
=
1
)
label
=
fluid
.
layers
.
data
(
name
=
"label"
,
shape
=
[
-
1
,
1
],
dtype
=
"int64"
,
lod_level
=
1
)
...
...
@@ -92,11 +94,12 @@ def stacked_lstmp_model(hidden_dim,
feat_
=
pd
.
read_input
(
feature
)
label_
=
pd
.
read_input
(
label
)
prediction
,
avg_cost
,
acc
=
_net_conf
(
feat_
,
label_
)
for
out
in
[
avg_cost
,
acc
]:
for
out
in
[
prediction
,
avg_cost
,
acc
]:
pd
.
write_output
(
out
)
# get mean loss and acc through every devices.
avg_cost
,
acc
=
pd
()
prediction
,
avg_cost
,
acc
=
pd
()
prediction
.
stop_gradient
=
True
avg_cost
=
fluid
.
layers
.
mean
(
x
=
avg_cost
)
acc
=
fluid
.
layers
.
mean
(
x
=
acc
)
else
:
...
...
fluid/DeepASR/tools/profile.py
浏览文件 @
7473ec05
...
...
@@ -31,6 +31,11 @@ def parse_args():
default
=
1
,
help
=
'The minimum sequence number of a batch data. '
'(default: %(default)d)'
)
parser
.
add_argument
(
'--frame_dim'
,
type
=
int
,
default
=
120
*
11
,
help
=
'Frame dimension of feature data. (default: %(default)d)'
)
parser
.
add_argument
(
'--stacked_num'
,
type
=
int
,
...
...
@@ -46,6 +51,11 @@ def parse_args():
type
=
int
,
default
=
1024
,
help
=
'Hidden size of lstmp unit. (default: %(default)d)'
)
parser
.
add_argument
(
'--class_num'
,
type
=
int
,
default
=
1749
,
help
=
'Number of classes in label. (default: %(default)d)'
)
parser
.
add_argument
(
'--learning_rate'
,
type
=
float
,
...
...
@@ -119,10 +129,11 @@ def profile(args):
"arg 'first_batches_to_skip' must not be smaller than 0."
)
_
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
frame_dim
=
args
.
frame_dim
,
hidden_dim
=
args
.
hidden_dim
,
proj_dim
=
args
.
proj_dim
,
stacked_num
=
args
.
stacked_num
,
class_num
=
1749
,
class_num
=
args
.
class_num
,
parallel
=
args
.
parallel
)
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
args
.
learning_rate
)
...
...
fluid/DeepASR/train.py
浏览文件 @
7473ec05
...
...
@@ -30,6 +30,11 @@ def parse_args():
default
=
1
,
help
=
'The minimum sequence number of a batch data. '
'(default: %(default)d)'
)
parser
.
add_argument
(
'--frame_dim'
,
type
=
int
,
default
=
120
*
11
,
help
=
'Frame dimension of feature data. (default: %(default)d)'
)
parser
.
add_argument
(
'--stacked_num'
,
type
=
int
,
...
...
@@ -45,6 +50,11 @@ def parse_args():
type
=
int
,
default
=
1024
,
help
=
'Hidden size of lstmp unit. (default: %(default)d)'
)
parser
.
add_argument
(
'--class_num'
,
type
=
int
,
default
=
1749
,
help
=
'Number of classes in label. (default: %(default)d)'
)
parser
.
add_argument
(
'--pass_num'
,
type
=
int
,
...
...
@@ -137,10 +147,11 @@ def train(args):
os
.
mkdir
(
args
.
infer_models
)
prediction
,
avg_cost
,
accuracy
=
stacked_lstmp_model
(
frame_dim
=
args
.
frame_dim
,
hidden_dim
=
args
.
hidden_dim
,
proj_dim
=
args
.
proj_dim
,
stacked_num
=
args
.
stacked_num
,
class_num
=
1749
,
class_num
=
args
.
class_num
,
parallel
=
args
.
parallel
)
# program for test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录