Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
0a50868d
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看板
提交
0a50868d
编写于
4月 20, 2020
作者:
O
overlordmax
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs
上级
c75dbb37
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
24 addition
and
30 deletion
+24
-30
PaddleRec/multi-task/MMoE/README.md
PaddleRec/multi-task/MMoE/README.md
+1
-1
PaddleRec/multi-task/MMoE/args.py
PaddleRec/multi-task/MMoE/args.py
+3
-4
PaddleRec/multi-task/MMoE/create_data.sh
PaddleRec/multi-task/MMoE/create_data.sh
+0
-1
PaddleRec/multi-task/MMoE/data_preparation.py
PaddleRec/multi-task/MMoE/data_preparation.py
+2
-3
PaddleRec/multi-task/MMoE/mmoe_train.py
PaddleRec/multi-task/MMoE/mmoe_train.py
+5
-3
PaddleRec/multi-task/Share_bottom/README.md
PaddleRec/multi-task/Share_bottom/README.md
+1
-1
PaddleRec/multi-task/Share_bottom/args.py
PaddleRec/multi-task/Share_bottom/args.py
+2
-10
PaddleRec/multi-task/Share_bottom/data_preparation.py
PaddleRec/multi-task/Share_bottom/data_preparation.py
+2
-4
PaddleRec/multi-task/Share_bottom/share_bottom.py
PaddleRec/multi-task/Share_bottom/share_bottom.py
+5
-2
PaddleRec/multi-task/Share_bottom/train_gpu.sh
PaddleRec/multi-task/Share_bottom/train_gpu.sh
+3
-1
未找到文件。
PaddleRec/multi-task/MMoE/README.md
浏览文件 @
0a50868d
...
...
@@ -50,7 +50,7 @@ train_path="data/census-income.data"
test_path
=
"data/census-income.test"
train_data_path
=
"train_data/"
test_data_path
=
"test_data/"
pip
install
-r
requirements.txt
wget
-P
data/ https://archive.ics.uci.edu/ml/machine-learning-databases/census-income-mld/census.tar.gz
tar
-zxvf
data/census.tar.gz
-C
data/
...
...
PaddleRec/multi-task/MMoE/args.py
浏览文件 @
0a50868d
...
...
@@ -30,9 +30,9 @@ def parse_args():
parser
.
add_argument
(
"--epochs"
,
type
=
int
,
default
=
400
,
help
=
"epochs"
)
parser
.
add_argument
(
"--batch_size"
,
type
=
int
,
default
=
32
,
help
=
"batch_size"
)
parser
.
add_argument
(
'--use_gpu'
,
type
=
int
,
default
=
0
,
help
=
'whether using gpu'
)
parser
.
add_argument
(
'--model_dir'
,
type
=
str
,
default
=
'
./
model_dir'
,
help
=
"model_dir"
)
parser
.
add_argument
(
'--train_data_path'
,
type
=
str
,
default
=
'
./
train_data'
,
help
=
"train_data_path"
)
parser
.
add_argument
(
'--test_data_path'
,
type
=
str
,
default
=
'
./
test_data'
,
help
=
"test_data_path"
)
parser
.
add_argument
(
'--model_dir'
,
type
=
str
,
default
=
'model_dir'
,
help
=
"model_dir"
)
parser
.
add_argument
(
'--train_data_path'
,
type
=
str
,
default
=
'train_data'
,
help
=
"train_data_path"
)
parser
.
add_argument
(
'--test_data_path'
,
type
=
str
,
default
=
'test_data'
,
help
=
"test_data_path"
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -43,6 +43,5 @@ def data_preparation_args():
parser
.
add_argument
(
'--train_data_path'
,
type
=
str
,
default
=
''
,
help
=
"train_data_path"
)
parser
.
add_argument
(
'--test_data_path'
,
type
=
str
,
default
=
''
,
help
=
"test_data_path"
)
parser
.
add_argument
(
'--validation_data_path'
,
type
=
str
,
default
=
''
,
help
=
"validation_data_path"
)
args
=
parser
.
parse_args
()
return
args
PaddleRec/multi-task/MMoE/create_data.sh
浏览文件 @
0a50868d
...
...
@@ -5,7 +5,6 @@ train_path="data/census-income.data"
test_path
=
"data/census-income.test"
train_data_path
=
"train_data/"
test_data_path
=
"test_data/"
pip
install
-r
requirements.txt
wget
-P
data/ https://archive.ics.uci.edu/ml/machine-learning-databases/census-income-mld/census.tar.gz
...
...
PaddleRec/multi-task/MMoE/data_preparation.py
浏览文件 @
0a50868d
...
...
@@ -18,8 +18,7 @@ def fun2(x):
return
0
def
data_preparation
(
train_path
,
test_path
,
train_data_path
,
test_data_path
,
validation_data_path
):
def
data_preparation
(
train_path
,
test_path
,
train_data_path
,
test_data_path
):
# The column names are from
# https://www2.1010data.com/documentationcenter/prod/Tutorials/MachineLearningExamples/CensusIncomeDataSet.html
column_names
=
[
...
...
@@ -102,4 +101,4 @@ def data_preparation(train_path, test_path, train_data_path, test_data_path,
args
=
data_preparation_args
()
data_preparation
(
args
.
train_path
,
args
.
test_path
,
args
.
train_data_path
,
args
.
test_data_path
,
args
.
validation_data_path
)
args
.
test_data_path
)
PaddleRec/multi-task/MMoE/mmoe_train.py
浏览文件 @
0a50868d
...
...
@@ -69,8 +69,11 @@ def MMOE(feature_size=499,expert_num=8, gate_num=2, expert_size=16, tower_size=8
label_income_1
=
fluid
.
layers
.
slice
(
label_income
,
axes
=
[
1
],
starts
=
[
1
],
ends
=
[
2
])
label_marital_1
=
fluid
.
layers
.
slice
(
label_marital
,
axes
=
[
1
],
starts
=
[
1
],
ends
=
[
2
])
auc_income
,
batch_auc_1
,
auc_states_1
=
fluid
.
layers
.
auc
(
input
=
output_layers
[
0
],
label
=
fluid
.
layers
.
cast
(
x
=
label_income_1
,
dtype
=
'int64'
))
auc_marital
,
batch_auc_2
,
auc_states_2
=
fluid
.
layers
.
auc
(
input
=
output_layers
[
1
],
label
=
fluid
.
layers
.
cast
(
x
=
label_marital_1
,
dtype
=
'int64'
))
pred_income
=
fluid
.
layers
.
clip
(
output_layers
[
0
],
min
=
1e-10
,
max
=
1.0
-
1e-10
)
pred_marital
=
fluid
.
layers
.
clip
(
output_layers
[
1
],
min
=
1e-10
,
max
=
1.0
-
1e-10
)
auc_income
,
batch_auc_1
,
auc_states_1
=
fluid
.
layers
.
auc
(
input
=
pred_income
,
label
=
fluid
.
layers
.
cast
(
x
=
label_income_1
,
dtype
=
'int64'
))
auc_marital
,
batch_auc_2
,
auc_states_2
=
fluid
.
layers
.
auc
(
input
=
pred_marital
,
label
=
fluid
.
layers
.
cast
(
x
=
label_marital_1
,
dtype
=
'int64'
))
avg_cost_income
=
fluid
.
layers
.
mean
(
x
=
cost_income
)
avg_cost_marital
=
fluid
.
layers
.
mean
(
x
=
cost_marital
)
...
...
@@ -116,7 +119,6 @@ test_loader = fluid.io.DataLoader.from_generator(feed_list=data_list, capacity=b
test_loader
.
set_sample_list_generator
(
test_reader
,
places
=
place
)
auc_income_list
=
[]
auc_marital_list
=
[]
mmoe_res_file
=
open
(
'mmoe_res.txt'
,
'w'
,
encoding
=
'utf-8'
)
for
epoch
in
range
(
epochs
):
for
var
in
auc_states_1
:
# reset auc states
set_zero
(
var
.
name
,
place
=
place
)
...
...
PaddleRec/multi-task/Share_bottom/README.md
浏览文件 @
0a50868d
...
...
@@ -50,7 +50,7 @@ train_path="data/census-income.data"
test_path
=
"data/census-income.test"
train_data_path
=
"train_data/"
test_data_path
=
"test_data/"
pip
install
-r
requirements.txt
wget
-P
data/ https://archive.ics.uci.edu/ml/machine-learning-databases/census-income-mld/census.tar.gz
tar
-zxvf
data/census.tar.gz
-C
data/
...
...
PaddleRec/multi-task/Share_bottom/args.py
浏览文件 @
0a50868d
...
...
@@ -40,15 +40,7 @@ def data_preparation_args():
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
"--train_path"
,
type
=
str
,
default
=
''
,
help
=
"train_path"
)
parser
.
add_argument
(
"--test_path"
,
type
=
str
,
default
=
''
,
help
=
"test_path"
)
parser
.
add_argument
(
'--train_data_path'
,
type
=
str
,
default
=
'train_data'
,
help
=
"train_data_path"
)
parser
.
add_argument
(
'--test_data_path'
,
type
=
str
,
default
=
'test_data'
,
help
=
"test_data_path"
)
parser
.
add_argument
(
'--validation_data_path'
,
type
=
str
,
default
=
''
,
help
=
"validation_data_path"
)
parser
.
add_argument
(
'--train_data_path'
,
type
=
str
,
default
=
'train_data'
,
help
=
"train_data_path"
)
parser
.
add_argument
(
'--test_data_path'
,
type
=
str
,
default
=
'test_data'
,
help
=
"test_data_path"
)
args
=
parser
.
parse_args
()
return
args
PaddleRec/multi-task/Share_bottom/data_preparation.py
浏览文件 @
0a50868d
...
...
@@ -18,8 +18,7 @@ def fun2(x):
return
0
def
data_preparation
(
train_path
,
test_path
,
train_data_path
,
test_data_path
,
validation_data_path
):
def
data_preparation
(
train_path
,
test_path
,
train_data_path
,
test_data_path
):
# The column names are from
# https://www2.1010data.com/documentationcenter/prod/Tutorials/MachineLearningExamples/CensusIncomeDataSet.html
column_names
=
[
...
...
@@ -101,5 +100,4 @@ def data_preparation(train_path, test_path, train_data_path, test_data_path,
args
=
data_preparation_args
()
data_preparation
(
args
.
train_path
,
args
.
test_path
,
args
.
train_data_path
,
args
.
test_data_path
,
args
.
validation_data_path
)
data_preparation
(
args
.
train_path
,
args
.
test_path
,
args
.
train_data_path
,
args
.
test_data_path
)
PaddleRec/multi-task/Share_bottom/share_bottom.py
浏览文件 @
0a50868d
...
...
@@ -56,8 +56,11 @@ def share_bottom(feature_size=499,bottom_size=117,tower_nums=2,tower_size=8):
label_income_1
=
fluid
.
layers
.
slice
(
label_income
,
axes
=
[
1
],
starts
=
[
1
],
ends
=
[
2
])
label_marital_1
=
fluid
.
layers
.
slice
(
label_marital
,
axes
=
[
1
],
starts
=
[
1
],
ends
=
[
2
])
auc_income
,
batch_auc_1
,
auc_states_1
=
fluid
.
layers
.
auc
(
input
=
output_layers
[
0
],
label
=
fluid
.
layers
.
cast
(
x
=
label_income_1
,
dtype
=
'int64'
))
auc_marital
,
batch_auc_2
,
auc_states_2
=
fluid
.
layers
.
auc
(
input
=
output_layers
[
1
],
label
=
fluid
.
layers
.
cast
(
x
=
label_marital_1
,
dtype
=
'int64'
))
pred_income
=
fluid
.
layers
.
clip
(
output_layers
[
0
],
min
=
1e-10
,
max
=
1.0
-
1e-10
)
pred_marital
=
fluid
.
layers
.
clip
(
output_layers
[
1
],
min
=
1e-10
,
max
=
1.0
-
1e-10
)
auc_income
,
batch_auc_1
,
auc_states_1
=
fluid
.
layers
.
auc
(
input
=
pred_income
,
label
=
fluid
.
layers
.
cast
(
x
=
label_income_1
,
dtype
=
'int64'
))
auc_marital
,
batch_auc_2
,
auc_states_2
=
fluid
.
layers
.
auc
(
input
=
pred_marital
,
label
=
fluid
.
layers
.
cast
(
x
=
label_marital_1
,
dtype
=
'int64'
))
avg_cost_income
=
fluid
.
layers
.
mean
(
x
=
cost_income
)
avg_cost_marital
=
fluid
.
layers
.
mean
(
x
=
cost_marital
)
...
...
PaddleRec/multi-task/Share_bottom/train_gpu.sh
浏览文件 @
0a50868d
python share_bottom.py
--use_gpu
1
\
CUDA_VISIBLE_DEVICES
=
0
python share_bottom.py
--use_gpu
1
\
--epochs
100
\
--train_data_path
'train_data'
\
--test_data_path
'test_data'
\
--train_data_path
'.train_data'
\
--test_data_path
'.test_data'
\
--model_dir
'model_dir'
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录