Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleRec
提交
8228c894
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看板
提交
8228c894
编写于
6月 01, 2020
作者:
Y
yaoxuefeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update din yaml
上级
0ffc1dfe
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
22 deletion
+14
-22
models/rank/din/config.yaml
models/rank/din/config.yaml
+4
-1
models/rank/din/data/config.txt
models/rank/din/data/config.txt
+0
-3
models/rank/din/model.py
models/rank/din/model.py
+10
-18
未找到文件。
models/rank/din/config.yaml
浏览文件 @
8228c894
...
@@ -36,7 +36,9 @@ hyper_parameters:
...
@@ -36,7 +36,9 @@ hyper_parameters:
item_emb_size
:
64
item_emb_size
:
64
cat_emb_size
:
64
cat_emb_size
:
64
is_sparse
:
False
is_sparse
:
False
config_path
:
"
{workspace}/data/config.txt"
item_count
:
63001
cat_count
:
801
act
:
"
sigmoid"
act
:
"
sigmoid"
...
@@ -52,6 +54,7 @@ runner:
...
@@ -52,6 +54,7 @@ runner:
save_inference_interval
:
1
save_inference_interval
:
1
save_checkpoint_path
:
"
increment"
save_checkpoint_path
:
"
increment"
save_inference_path
:
"
inference"
save_inference_path
:
"
inference"
print_interval
:
1
-
name
:
infer_runner
-
name
:
infer_runner
trainer_class
:
single_infer
trainer_class
:
single_infer
epochs
:
1
epochs
:
1
...
...
models/rank/din/data/config.txt
已删除
100644 → 0
浏览文件 @
0ffc1dfe
192403
63001
801
models/rank/din/model.py
浏览文件 @
8228c894
...
@@ -31,10 +31,11 @@ class Model(ModelBase):
...
@@ -31,10 +31,11 @@ class Model(ModelBase):
self
.
is_sparse
=
envs
.
get_global_env
(
"hyper_parameters.is_sparse"
,
self
.
is_sparse
=
envs
.
get_global_env
(
"hyper_parameters.is_sparse"
,
False
)
False
)
#significant for speeding up the training process
#significant for speeding up the training process
self
.
config_path
=
envs
.
get_global_env
(
"hyper_parameters.config_path"
,
"data/config.txt"
)
self
.
use_DataLoader
=
envs
.
get_global_env
(
self
.
use_DataLoader
=
envs
.
get_global_env
(
"hyper_parameters.use_DataLoader"
,
False
)
"hyper_parameters.use_DataLoader"
,
False
)
self
.
item_count
=
envs
.
get_global_env
(
"hyper_parameters.item_count"
,
63001
)
self
.
cat_count
=
envs
.
get_global_env
(
"hyper_parameters.cat_count"
,
801
)
def
input_data
(
self
,
is_infer
=
False
,
**
kwargs
):
def
input_data
(
self
,
is_infer
=
False
,
**
kwargs
):
seq_len
=
-
1
seq_len
=
-
1
...
@@ -74,13 +75,6 @@ class Model(ModelBase):
...
@@ -74,13 +75,6 @@ class Model(ModelBase):
]
+
[
label
]
+
[
mask
]
+
[
target_item_seq
]
+
[
target_cat_seq
]
]
+
[
label
]
+
[
mask
]
+
[
target_item_seq
]
+
[
target_cat_seq
]
return
train_inputs
return
train_inputs
def
config_read
(
self
,
config_path
):
with
open
(
config_path
,
"r"
)
as
fin
:
user_count
=
int
(
fin
.
readline
().
strip
())
item_count
=
int
(
fin
.
readline
().
strip
())
cat_count
=
int
(
fin
.
readline
().
strip
())
return
user_count
,
item_count
,
cat_count
def
din_attention
(
self
,
hist
,
target_expand
,
mask
):
def
din_attention
(
self
,
hist
,
target_expand
,
mask
):
"""activation weight"""
"""activation weight"""
...
@@ -121,50 +115,48 @@ class Model(ModelBase):
...
@@ -121,50 +115,48 @@ class Model(ModelBase):
target_item_seq
=
inputs
[
6
]
target_item_seq
=
inputs
[
6
]
target_cat_seq
=
inputs
[
7
]
target_cat_seq
=
inputs
[
7
]
user_count
,
item_count
,
cat_count
=
self
.
config_read
(
self
.
config_path
)
item_emb_attr
=
fluid
.
ParamAttr
(
name
=
"item_emb"
)
item_emb_attr
=
fluid
.
ParamAttr
(
name
=
"item_emb"
)
cat_emb_attr
=
fluid
.
ParamAttr
(
name
=
"cat_emb"
)
cat_emb_attr
=
fluid
.
ParamAttr
(
name
=
"cat_emb"
)
hist_item_emb
=
fluid
.
embedding
(
hist_item_emb
=
fluid
.
embedding
(
input
=
hist_item_seq
,
input
=
hist_item_seq
,
size
=
[
item_count
,
self
.
item_emb_size
],
size
=
[
self
.
item_count
,
self
.
item_emb_size
],
param_attr
=
item_emb_attr
,
param_attr
=
item_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
hist_cat_emb
=
fluid
.
embedding
(
hist_cat_emb
=
fluid
.
embedding
(
input
=
hist_cat_seq
,
input
=
hist_cat_seq
,
size
=
[
cat_count
,
self
.
cat_emb_size
],
size
=
[
self
.
cat_count
,
self
.
cat_emb_size
],
param_attr
=
cat_emb_attr
,
param_attr
=
cat_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
target_item_emb
=
fluid
.
embedding
(
target_item_emb
=
fluid
.
embedding
(
input
=
target_item
,
input
=
target_item
,
size
=
[
item_count
,
self
.
item_emb_size
],
size
=
[
self
.
item_count
,
self
.
item_emb_size
],
param_attr
=
item_emb_attr
,
param_attr
=
item_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
target_cat_emb
=
fluid
.
embedding
(
target_cat_emb
=
fluid
.
embedding
(
input
=
target_cat
,
input
=
target_cat
,
size
=
[
cat_count
,
self
.
cat_emb_size
],
size
=
[
self
.
cat_count
,
self
.
cat_emb_size
],
param_attr
=
cat_emb_attr
,
param_attr
=
cat_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
target_item_seq_emb
=
fluid
.
embedding
(
target_item_seq_emb
=
fluid
.
embedding
(
input
=
target_item_seq
,
input
=
target_item_seq
,
size
=
[
item_count
,
self
.
item_emb_size
],
size
=
[
self
.
item_count
,
self
.
item_emb_size
],
param_attr
=
item_emb_attr
,
param_attr
=
item_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
target_cat_seq_emb
=
fluid
.
embedding
(
target_cat_seq_emb
=
fluid
.
embedding
(
input
=
target_cat_seq
,
input
=
target_cat_seq
,
size
=
[
cat_count
,
self
.
cat_emb_size
],
size
=
[
self
.
cat_count
,
self
.
cat_emb_size
],
param_attr
=
cat_emb_attr
,
param_attr
=
cat_emb_attr
,
is_sparse
=
self
.
is_sparse
)
is_sparse
=
self
.
is_sparse
)
item_b
=
fluid
.
embedding
(
item_b
=
fluid
.
embedding
(
input
=
target_item
,
input
=
target_item
,
size
=
[
item_count
,
1
],
size
=
[
self
.
item_count
,
1
],
param_attr
=
fluid
.
initializer
.
Constant
(
value
=
0.0
))
param_attr
=
fluid
.
initializer
.
Constant
(
value
=
0.0
))
hist_seq_concat
=
fluid
.
layers
.
concat
(
hist_seq_concat
=
fluid
.
layers
.
concat
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录