Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_strategy_cvr
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
gm_strategy_cvr
Commits
f86662b3
Commit
f86662b3
authored
Sep 01, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try diary cross feature
parent
084806b0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
fe.py
src/models/esmm/fe/fe.py
+6
-0
train_diary.py
src/train_diary.py
+5
-3
No files found.
src/models/esmm/fe/fe.py
View file @
f86662b3
...
...
@@ -33,5 +33,11 @@ def build_features(df, int_columns, float_columns, categorical_columns):
categorical_features
.
append
(
fc
.
indicator_column
(
fc
.
categorical_column_with_vocabulary_list
(
col
,
create_vocabulary_list
(
df
,
col
))))
# TODO try cross feature
a
=
fc
.
categorical_column_with_vocabulary_list
(
"device_fd"
,
create_vocabulary_list
(
df
,
"device_fd"
))
b
=
fc
.
categorical_column_with_vocabulary_list
(
"content_fd"
,
create_vocabulary_list
(
df
,
"content_fd"
))
c
=
tf
.
feature_column
.
crossed_column
([
a
,
b
],
hash_bucket_size
=
10
)
categorical_features
.
append
(
tf
.
feature_column
.
indicator_column
(
c
))
all_features
=
(
numeric_features
+
categorical_features
)
return
all_features
src/train_diary.py
View file @
f86662b3
...
...
@@ -50,7 +50,7 @@ def main():
train_df
,
val_df
=
train_test_split
(
train_df
,
test_size
=
0.2
)
all_features
=
fe
.
build_features
(
df
,
diary_fe
.
INT_COLUMNS
,
diary_fe
.
FLOAT_COLUMNS
,
diary_fe
.
CATEGORICAL_COLUMNS
)
params
=
{
"feature_columns"
:
all_features
,
"hidden_units"
:
[
200
,
80
,
2
],
"learning_rate"
:
0.2
}
params
=
{
"feature_columns"
:
all_features
,
"hidden_units"
:
[
360
,
200
,
80
,
2
],
"learning_rate"
:
0.2
}
model_path
=
str
(
Path
(
"/data/files/model_tmp/diary/"
)
.
expanduser
())
if
os
.
path
.
exists
(
model_path
):
shutil
.
rmtree
(
model_path
)
...
...
@@ -61,7 +61,8 @@ def main():
estimator_config
=
tf
.
estimator
.
RunConfig
(
session_config
=
session_config
)
model
=
tf
.
estimator
.
Estimator
(
model_fn
=
esmm_model_fn
,
params
=
params
,
model_dir
=
model_path
,
config
=
estimator_config
)
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
50000
)
# TODO 50000
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
15000
)
eval_spec
=
tf
.
estimator
.
EvalSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
val_df
,
shuffle
=
False
))
res
=
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
print
(
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
)
...
...
@@ -73,7 +74,8 @@ def main():
model_export_path
=
str
(
Path
(
"/data/files/models/diary"
)
.
expanduser
())
save_path
=
model_export
(
model
,
all_features
,
model_export_path
)
print
(
"save to: "
+
save_path
)
set_essm_model_save_path
(
"diary"
,
save_path
)
# TODO save model
# set_essm_model_save_path("diary", save_path)
print
(
"============================================================"
)
# save_path = str(Path("~/Desktop/models/1596012827").expanduser()) # local
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment