Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
71971366
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看板
提交
71971366
编写于
4月 22, 2020
作者:
O
overlordmax
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/models
into pr_04221554
上级
e8d0d7f3
ac69979e
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
47 addition
and
37 deletion
+47
-37
PaddleRec/ctr/din/.run_ce.sh
PaddleRec/ctr/din/.run_ce.sh
+0
-0
PaddleRec/ctr/din/README.md
PaddleRec/ctr/din/README.md
+0
-0
PaddleRec/ctr/din/__init__.py
PaddleRec/ctr/din/__init__.py
+0
-0
PaddleRec/ctr/din/_ce.py
PaddleRec/ctr/din/_ce.py
+9
-8
PaddleRec/ctr/din/cluster_train.py
PaddleRec/ctr/din/cluster_train.py
+0
-0
PaddleRec/ctr/din/cluster_train.sh
PaddleRec/ctr/din/cluster_train.sh
+0
-0
PaddleRec/ctr/din/data/build_dataset.py
PaddleRec/ctr/din/data/build_dataset.py
+0
-0
PaddleRec/ctr/din/data/convert_pd.py
PaddleRec/ctr/din/data/convert_pd.py
+0
-0
PaddleRec/ctr/din/data/data_process.sh
PaddleRec/ctr/din/data/data_process.sh
+0
-0
PaddleRec/ctr/din/data/remap_id.py
PaddleRec/ctr/din/data/remap_id.py
+0
-0
PaddleRec/ctr/din/infer.py
PaddleRec/ctr/din/infer.py
+6
-4
PaddleRec/ctr/din/network.py
PaddleRec/ctr/din/network.py
+5
-8
PaddleRec/ctr/din/reader.py
PaddleRec/ctr/din/reader.py
+3
-4
PaddleRec/ctr/din/train.py
PaddleRec/ctr/din/train.py
+24
-13
未找到文件。
PaddleRec/din/.run_ce.sh
→
PaddleRec/
ctr/
din/.run_ce.sh
浏览文件 @
71971366
文件已移动
PaddleRec/din/README.md
→
PaddleRec/
ctr/
din/README.md
浏览文件 @
71971366
文件已移动
PaddleRec/din/__init__.py
→
PaddleRec/
ctr/
din/__init__.py
浏览文件 @
71971366
文件已移动
PaddleRec/din/_ce.py
→
PaddleRec/
ctr/
din/_ce.py
浏览文件 @
71971366
...
...
@@ -6,18 +6,19 @@ sys.path.append(os.environ['ceroot'])
from
kpi
import
CostKpi
from
kpi
import
DurationKpi
each_pass_duration_card1_kpi
=
DurationKpi
(
'each_pass_duration_card1'
,
0.08
,
0
,
actived
=
True
)
each_pass_duration_card1_kpi
=
DurationKpi
(
'each_pass_duration_card1'
,
0.08
,
0
,
actived
=
True
)
train_loss_card1_kpi
=
CostKpi
(
'train_loss_card1'
,
0.08
,
0
)
each_pass_duration_card4_kpi
=
DurationKpi
(
'each_pass_duration_card4'
,
0.08
,
0
,
actived
=
True
)
each_pass_duration_card4_kpi
=
DurationKpi
(
'each_pass_duration_card4'
,
0.08
,
0
,
actived
=
True
)
train_loss_card4_kpi
=
CostKpi
(
'train_loss_card4'
,
0.08
,
0
)
tracking_kpis
=
[
each_pass_duration_card1_kpi
,
train_loss_card1_kpi
,
each_pass_duration_card4_kpi
,
train_loss_card4_kpi
,
]
each_pass_duration_card1_kpi
,
train_loss_card1_kpi
,
each_pass_duration_card4_kpi
,
train_loss_card4_kpi
,
]
def
parse_log
(
log
):
...
...
PaddleRec/din/cluster_train.py
→
PaddleRec/
ctr/
din/cluster_train.py
浏览文件 @
71971366
文件已移动
PaddleRec/din/cluster_train.sh
→
PaddleRec/
ctr/
din/cluster_train.sh
浏览文件 @
71971366
文件已移动
PaddleRec/din/data/build_dataset.py
→
PaddleRec/
ctr/
din/data/build_dataset.py
浏览文件 @
71971366
文件已移动
PaddleRec/din/data/convert_pd.py
→
PaddleRec/
ctr/
din/data/convert_pd.py
浏览文件 @
71971366
文件已移动
PaddleRec/din/data/data_process.sh
→
PaddleRec/
ctr/
din/data/data_process.sh
浏览文件 @
71971366
文件已移动
PaddleRec/din/data/remap_id.py
→
PaddleRec/
ctr/
din/data/remap_id.py
浏览文件 @
71971366
文件已移动
PaddleRec/din/infer.py
→
PaddleRec/
ctr/
din/infer.py
浏览文件 @
71971366
...
...
@@ -79,16 +79,18 @@ def infer():
fetch_targets
]
=
fluid
.
io
.
load_inference_model
(
model_path
,
exe
)
loader
=
fluid
.
io
.
DataLoader
.
from_generator
(
feed_list
=
[
inference_program
.
block
(
0
).
var
(
e
)
for
e
in
feed_target_names
],
capacity
=
10000
,
iterable
=
True
)
feed_list
=
[
inference_program
.
block
(
0
).
var
(
e
)
for
e
in
feed_target_names
],
capacity
=
10000
,
iterable
=
True
)
loader
.
set_sample_list_generator
(
data_reader
,
places
=
place
)
loss_sum
=
0.0
score
=
[]
count
=
0
for
data
in
loader
():
res
=
exe
.
run
(
inference_program
,
feed
=
data
,
fetch_list
=
fetch_targets
)
res
=
exe
.
run
(
inference_program
,
feed
=
data
,
fetch_list
=
fetch_targets
)
loss_sum
+=
res
[
0
]
label_data
=
list
(
np
.
array
(
data
[
0
][
"label"
]))
for
i
in
range
(
len
(
label_data
)):
...
...
PaddleRec/din/network.py
→
PaddleRec/
ctr/
din/network.py
浏览文件 @
71971366
...
...
@@ -14,6 +14,7 @@
import
paddle.fluid
as
fluid
def
din_attention
(
hist
,
target_expand
,
mask
):
"""activation weight"""
...
...
@@ -61,14 +62,10 @@ def network(item_count, cat_count):
name
=
"hist_item_seq"
,
shape
=
[
None
,
seq_len
],
dtype
=
"int64"
)
hist_cat_seq
=
fluid
.
data
(
name
=
"hist_cat_seq"
,
shape
=
[
None
,
seq_len
],
dtype
=
"int64"
)
target_item
=
fluid
.
data
(
name
=
"target_item"
,
shape
=
[
None
],
dtype
=
"int64"
)
target_cat
=
fluid
.
data
(
name
=
"target_cat"
,
shape
=
[
None
],
dtype
=
"int64"
)
label
=
fluid
.
data
(
name
=
"label"
,
shape
=
[
None
,
1
],
dtype
=
"float32"
)
mask
=
fluid
.
data
(
name
=
"mask"
,
shape
=
[
None
,
seq_len
,
1
],
dtype
=
"float32"
)
target_item
=
fluid
.
data
(
name
=
"target_item"
,
shape
=
[
None
],
dtype
=
"int64"
)
target_cat
=
fluid
.
data
(
name
=
"target_cat"
,
shape
=
[
None
],
dtype
=
"int64"
)
label
=
fluid
.
data
(
name
=
"label"
,
shape
=
[
None
,
1
],
dtype
=
"float32"
)
mask
=
fluid
.
data
(
name
=
"mask"
,
shape
=
[
None
,
seq_len
,
1
],
dtype
=
"float32"
)
target_item_seq
=
fluid
.
data
(
name
=
"target_item_seq"
,
shape
=
[
None
,
seq_len
],
dtype
=
"int64"
)
target_cat_seq
=
fluid
.
data
(
...
...
PaddleRec/din/reader.py
→
PaddleRec/
ctr/
din/reader.py
浏览文件 @
71971366
...
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle
import
pickle
def
pad_batch_data
(
input
,
max_len
):
res
=
np
.
array
([
x
+
[
0
]
*
(
max_len
-
len
(
x
))
for
x
in
input
])
res
=
res
.
astype
(
"int64"
).
reshape
([
-
1
,
max_len
])
...
...
@@ -33,11 +34,9 @@ def make_data(b):
[[
0
]
*
x
+
[
-
1e9
]
*
(
max_len
-
x
)
for
x
in
len_array
]).
reshape
(
[
-
1
,
max_len
,
1
])
target_item_seq
=
np
.
array
(
[[
x
[
2
]]
*
max_len
for
x
in
b
]).
astype
(
"int64"
).
reshape
(
[
-
1
,
max_len
])
[[
x
[
2
]]
*
max_len
for
x
in
b
]).
astype
(
"int64"
).
reshape
([
-
1
,
max_len
])
target_cat_seq
=
np
.
array
(
[[
x
[
3
]]
*
max_len
for
x
in
b
]).
astype
(
"int64"
).
reshape
(
[
-
1
,
max_len
])
[[
x
[
3
]]
*
max_len
for
x
in
b
]).
astype
(
"int64"
).
reshape
([
-
1
,
max_len
])
res
=
[]
for
i
in
range
(
len
(
b
)):
res
.
append
([
...
...
PaddleRec/din/train.py
→
PaddleRec/
ctr/
din/train.py
浏览文件 @
71971366
...
...
@@ -33,11 +33,20 @@ logger.setLevel(logging.INFO)
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
"din"
)
parser
.
add_argument
(
'--config_path'
,
type
=
str
,
default
=
'data/config.txt'
,
help
=
'dir of config'
)
'--config_path'
,
type
=
str
,
default
=
'data/config.txt'
,
help
=
'dir of config'
)
parser
.
add_argument
(
'--train_dir'
,
type
=
str
,
default
=
'data/paddle_train.txt'
,
help
=
'dir of train file'
)
'--train_dir'
,
type
=
str
,
default
=
'data/paddle_train.txt'
,
help
=
'dir of train file'
)
parser
.
add_argument
(
'--model_dir'
,
type
=
str
,
default
=
'din_amazon'
,
help
=
'dir of saved model'
)
'--model_dir'
,
type
=
str
,
default
=
'din_amazon'
,
help
=
'dir of saved model'
)
parser
.
add_argument
(
'--batch_size'
,
type
=
int
,
default
=
16
,
help
=
'number of batch size'
)
parser
.
add_argument
(
...
...
@@ -45,15 +54,19 @@ def parse_args():
parser
.
add_argument
(
'--use_cuda'
,
type
=
int
,
default
=
0
,
help
=
'whether to use gpu'
)
parser
.
add_argument
(
'--parallel'
,
type
=
int
,
default
=
0
,
help
=
'whether to use parallel executor'
)
'--parallel'
,
type
=
int
,
default
=
0
,
help
=
'whether to use parallel executor'
)
parser
.
add_argument
(
'--base_lr'
,
type
=
float
,
default
=
0.85
,
help
=
'based learning rate'
)
parser
.
add_argument
(
'--num_devices'
,
type
=
int
,
default
=
1
,
help
=
'Number of GPU devices'
)
parser
.
add_argument
(
'--enable_ce'
,
action
=
'store_true'
,
help
=
'If set, run the task with continuous evaluation logs.'
)
parser
.
add_argument
(
'--batch_num'
,
type
=
int
,
help
=
"batch num for ce"
)
'--enable_ce'
,
action
=
'store_true'
,
help
=
'If set, run the task with continuous evaluation logs.'
)
parser
.
add_argument
(
'--batch_num'
,
type
=
int
,
help
=
"batch num for ce"
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -133,8 +146,8 @@ def train():
if
(
global_step
>
400000
and
global_step
%
PRINT_STEP
==
0
)
or
(
global_step
<=
400000
and
global_step
%
50000
==
0
):
save_dir
=
os
.
path
.
join
(
args
.
model_dir
,
"global_step_"
+
str
(
global_step
))
save_dir
=
os
.
path
.
join
(
args
.
model_dir
,
"global_step_"
+
str
(
global_step
))
feed_var_name
=
[
"hist_item_seq"
,
"hist_cat_seq"
,
"target_item"
,
"target_cat"
,
"label"
,
"mask"
,
"target_item_seq"
,
...
...
@@ -156,10 +169,8 @@ def train():
ce_time
=
total_time
[
-
1
]
except
:
print
(
"ce info error"
)
print
(
"kpis
\t
each_pass_duration_card%s
\t
%s"
%
(
gpu_num
,
ce_time
))
print
(
"kpis
\t
train_loss_card%s
\t
%s"
%
(
gpu_num
,
ce_loss
))
print
(
"kpis
\t
each_pass_duration_card%s
\t
%s"
%
(
gpu_num
,
ce_time
))
print
(
"kpis
\t
train_loss_card%s
\t
%s"
%
(
gpu_num
,
ce_loss
))
def
get_cards
(
args
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录