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
79a750fa
Commit
79a750fa
authored
Jul 21, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add printer
parent
0996dcf2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
main.py
src/main.py
+36
-1
model.py
src/models/esmm/model.py
+3
-1
No files found.
src/main.py
View file @
79a750fa
...
...
@@ -87,28 +87,63 @@ def main():
@time_cost
def
test1
():
time_1
=
timeit
.
default_timer
()
user1
=
join_device_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
300
),
redis_device_df
,
redis_diary_df
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join df cost {:.5f}s"
.
format
(
total_1
))
time_1
=
timeit
.
default_timer
()
model_predict
(
user1
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
))
@time_cost
def
test2
():
time_1
=
timeit
.
default_timer
()
user1
=
join_device_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
300
),
redis_device_df
,
redis_diary_df
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join df cost {:.5f}s"
.
format
(
total_1
))
time_1
=
timeit
.
default_timer
()
model_predict
(
user1
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
))
@time_cost
def
test3
():
time_1
=
timeit
.
default_timer
()
user1
=
join_device_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
300
),
redis_device_df
,
redis_diary_df
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join df cost {:.5f}s"
.
format
(
total_1
))
time_1
=
timeit
.
default_timer
()
model_predict
(
user1
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
))
@time_cost
def
test4
():
time_1
=
timeit
.
default_timer
()
user1
=
join_device_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
300
),
redis_device_df
,
redis_diary_df
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join df cost {:.5f}s"
.
format
(
total_1
))
time_1
=
timeit
.
default_timer
()
model_predict
(
user1
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
))
@time_cost
def
test5
():
time_1
=
timeit
.
default_timer
()
user1
=
join_device_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
300
),
redis_device_df
,
redis_diary_df
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join df cost {:.5f}s"
.
format
(
total_1
))
time_1
=
timeit
.
default_timer
()
model_predict
(
user1
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
))
test1
()
test2
()
...
...
@@ -117,7 +152,7 @@ def main():
test5
()
total_time
=
(
time
.
time
()
-
time_begin
)
/
60
print
(
"cost {:.2f} mins at {}"
.
format
(
total_time
,
datetime
.
now
()))
print
(
"
total
cost {:.2f} mins at {}"
.
format
(
total_time
,
datetime
.
now
()))
if
__name__
==
"__main__"
:
...
...
src/models/esmm/model.py
View file @
79a750fa
import
timeit
import
tensorflow
as
tf
from
tensorflow
import
feature_column
as
fc
from
tensorflow.python.estimator.canned
import
head
as
head_lib
from
tensorflow.python.ops.losses
import
losses
import
timeit
def
build_deep_layer
(
net
,
params
):
...
...
@@ -115,4 +116,5 @@ def model_predict(inputs, predict_fn):
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"prediction cost {:.5f}s"
.
format
(
total_1
))
# print(predictions)
# TODO get the diary ids
return
predictions
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