Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleRec
提交
a3ddeec0
P
PaddleRec
项目概览
PaddlePaddle
/
PaddleRec
通知
68
Star
12
Fork
5
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
27
列表
看板
标记
里程碑
合并请求
10
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
27
Issue
27
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a3ddeec0
编写于
5月 29, 2020
作者:
X
xjqbest
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
a09255fb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
16 deletion
+18
-16
core/reader.py
core/reader.py
+4
-2
core/trainers/single_infer.py
core/trainers/single_infer.py
+6
-6
core/trainers/single_trainer.py
core/trainers/single_trainer.py
+3
-3
core/utils/dataset_instance.py
core/utils/dataset_instance.py
+2
-2
models/rank/dnn/model.py
models/rank/dnn/model.py
+3
-3
未找到文件。
core/reader.py
浏览文件 @
a3ddeec0
...
@@ -59,10 +59,12 @@ class SlotReader(dg.MultiSlotDataGenerator):
...
@@ -59,10 +59,12 @@ class SlotReader(dg.MultiSlotDataGenerator):
def
init
(
self
,
sparse_slots
,
dense_slots
,
padding
=
0
):
def
init
(
self
,
sparse_slots
,
dense_slots
,
padding
=
0
):
from
operator
import
mul
from
operator
import
mul
self
.
sparse_slots
=
[]
self
.
sparse_slots
=
[]
if
sparse_slots
.
strip
()
!=
"#"
:
if
sparse_slots
.
strip
()
!=
"#"
and
sparse_slots
.
strip
(
)
!=
"?"
and
sparse_slots
.
strip
()
!=
""
:
self
.
sparse_slots
=
sparse_slots
.
strip
().
split
(
" "
)
self
.
sparse_slots
=
sparse_slots
.
strip
().
split
(
" "
)
self
.
dense_slots
=
[]
self
.
dense_slots
=
[]
if
dense_slots
.
strip
()
!=
"#"
:
if
dense_slots
.
strip
()
!=
"#"
and
dense_slots
.
strip
(
)
!=
"?"
and
dense_slots
.
strip
()
!=
""
:
self
.
dense_slots
=
dense_slots
.
strip
().
split
(
" "
)
self
.
dense_slots
=
dense_slots
.
strip
().
split
(
" "
)
self
.
dense_slots_shape
=
[
self
.
dense_slots_shape
=
[
reduce
(
mul
,
reduce
(
mul
,
...
...
core/trainers/single_infer.py
浏览文件 @
a3ddeec0
...
@@ -78,14 +78,14 @@ class SingleInfer(TranspileTrainer):
...
@@ -78,14 +78,14 @@ class SingleInfer(TranspileTrainer):
pipe_cmd
=
"python {} {} {} {}"
.
format
(
reader
,
reader_class
,
pipe_cmd
=
"python {} {} {} {}"
.
format
(
reader
,
reader_class
,
"TRAIN"
,
self
.
_config_yaml
)
"TRAIN"
,
self
.
_config_yaml
)
else
:
else
:
if
sparse_slots
is
None
:
if
sparse_slots
==
""
:
sparse_slots
=
"
#
"
sparse_slots
=
"
?
"
if
dense_slots
is
None
:
if
dense_slots
==
""
:
dense_slots
=
"
#
"
dense_slots
=
"
?
"
padding
=
envs
.
get_global_env
(
name
+
"padding"
,
0
)
padding
=
envs
.
get_global_env
(
name
+
"padding"
,
0
)
pipe_cmd
=
"python {} {} {} {} {} {} {} {}"
.
format
(
pipe_cmd
=
"python {} {} {} {} {} {} {} {}"
.
format
(
reader
,
"slot"
,
"slot"
,
self
.
_config_yaml
,
"fake"
,
\
reader
,
"slot"
,
"slot"
,
self
.
_config_yaml
,
"fake"
,
\
sparse_slots
.
replace
(
" "
,
"
#"
),
dense_slots
.
replace
(
" "
,
"#
"
),
str
(
padding
))
sparse_slots
.
replace
(
" "
,
"
?"
),
dense_slots
.
replace
(
" "
,
"?
"
),
str
(
padding
))
dataset
=
fluid
.
DatasetFactory
().
create_dataset
()
dataset
=
fluid
.
DatasetFactory
().
create_dataset
()
dataset
.
set_batch_size
(
envs
.
get_global_env
(
name
+
"batch_size"
))
dataset
.
set_batch_size
(
envs
.
get_global_env
(
name
+
"batch_size"
))
...
@@ -290,7 +290,7 @@ class SingleInfer(TranspileTrainer):
...
@@ -290,7 +290,7 @@ class SingleInfer(TranspileTrainer):
def
load
(
self
,
is_fleet
=
False
):
def
load
(
self
,
is_fleet
=
False
):
name
=
"runner."
+
self
.
_runner_name
+
"."
name
=
"runner."
+
self
.
_runner_name
+
"."
dirname
=
envs
.
get_global_env
(
"epoch.
init_model_path"
,
None
)
dirname
=
envs
.
get_global_env
(
name
+
"
init_model_path"
,
None
)
if
dirname
is
None
or
dirname
==
""
:
if
dirname
is
None
or
dirname
==
""
:
return
return
print
(
"single_infer going to load "
,
dirname
)
print
(
"single_infer going to load "
,
dirname
)
...
...
core/trainers/single_trainer.py
浏览文件 @
a3ddeec0
...
@@ -73,13 +73,13 @@ class SingleTrainer(TranspileTrainer):
...
@@ -73,13 +73,13 @@ class SingleTrainer(TranspileTrainer):
"TRAIN"
,
self
.
_config_yaml
)
"TRAIN"
,
self
.
_config_yaml
)
else
:
else
:
if
sparse_slots
==
""
:
if
sparse_slots
==
""
:
sparse_slots
=
"
#
"
sparse_slots
=
"
?
"
if
dense_slots
==
""
:
if
dense_slots
==
""
:
dense_slots
=
"
#
"
dense_slots
=
"
?
"
padding
=
envs
.
get_global_env
(
name
+
"padding"
,
0
)
padding
=
envs
.
get_global_env
(
name
+
"padding"
,
0
)
pipe_cmd
=
"python {} {} {} {} {} {} {} {}"
.
format
(
pipe_cmd
=
"python {} {} {} {} {} {} {} {}"
.
format
(
reader
,
"slot"
,
"slot"
,
self
.
_config_yaml
,
"fake"
,
\
reader
,
"slot"
,
"slot"
,
self
.
_config_yaml
,
"fake"
,
\
sparse_slots
.
replace
(
" "
,
"
#"
),
dense_slots
.
replace
(
" "
,
"#
"
),
str
(
padding
))
sparse_slots
.
replace
(
" "
,
"
?"
),
dense_slots
.
replace
(
" "
,
"?
"
),
str
(
padding
))
dataset
=
fluid
.
DatasetFactory
().
create_dataset
()
dataset
=
fluid
.
DatasetFactory
().
create_dataset
()
dataset
.
set_batch_size
(
envs
.
get_global_env
(
name
+
"batch_size"
))
dataset
.
set_batch_size
(
envs
.
get_global_env
(
name
+
"batch_size"
))
...
...
core/utils/dataset_instance.py
浏览文件 @
a3ddeec0
...
@@ -32,8 +32,8 @@ elif sys.argv[2].upper() == "EVALUATE":
...
@@ -32,8 +32,8 @@ elif sys.argv[2].upper() == "EVALUATE":
else
:
else
:
reader_name
=
"SlotReader"
reader_name
=
"SlotReader"
namespace
=
sys
.
argv
[
4
]
namespace
=
sys
.
argv
[
4
]
sparse_slots
=
sys
.
argv
[
5
].
replace
(
"
#
"
,
" "
)
sparse_slots
=
sys
.
argv
[
5
].
replace
(
"
?
"
,
" "
)
dense_slots
=
sys
.
argv
[
6
].
replace
(
"
#
"
,
" "
)
dense_slots
=
sys
.
argv
[
6
].
replace
(
"
?
"
,
" "
)
padding
=
int
(
sys
.
argv
[
7
])
padding
=
int
(
sys
.
argv
[
7
])
yaml_abs_path
=
sys
.
argv
[
3
]
yaml_abs_path
=
sys
.
argv
[
3
]
...
...
models/rank/dnn/model.py
浏览文件 @
a3ddeec0
...
@@ -36,7 +36,7 @@ class Model(ModelBase):
...
@@ -36,7 +36,7 @@ class Model(ModelBase):
def
net
(
self
,
input
,
is_infer
=
False
):
def
net
(
self
,
input
,
is_infer
=
False
):
self
.
sparse_inputs
=
self
.
_sparse_data_var
[
1
:]
self
.
sparse_inputs
=
self
.
_sparse_data_var
[
1
:]
self
.
dense_input
=
self
.
_dense_data_var
[
0
]
self
.
dense_input
=
[]
#
self._dense_data_var[0]
self
.
label_input
=
self
.
_sparse_data_var
[
0
]
self
.
label_input
=
self
.
_sparse_data_var
[
0
]
def
embedding_layer
(
input
):
def
embedding_layer
(
input
):
...
@@ -52,8 +52,8 @@ class Model(ModelBase):
...
@@ -52,8 +52,8 @@ class Model(ModelBase):
return
emb_sum
return
emb_sum
sparse_embed_seq
=
list
(
map
(
embedding_layer
,
self
.
sparse_inputs
))
sparse_embed_seq
=
list
(
map
(
embedding_layer
,
self
.
sparse_inputs
))
concated
=
fluid
.
layers
.
concat
(
concated
=
fluid
.
layers
.
concat
(
sparse_embed_seq
,
axis
=
1
)
sparse_embed_seq
+
[
self
.
dense_input
],
axis
=
1
)
#
sparse_embed_seq + [self.dense_input], axis=1)
fcs
=
[
concated
]
fcs
=
[
concated
]
hidden_layers
=
envs
.
get_global_env
(
"hyper_parameters.fc_sizes"
)
hidden_layers
=
envs
.
get_global_env
(
"hyper_parameters.fc_sizes"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录