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
2f918780
Commit
2f918780
authored
Jul 21, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update field
parent
a01adb19
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
requirements.txt
requirements.txt
+1
-1
main.py
src/main.py
+6
-1
model.py
src/models/esmm/model.py
+2
-1
No files found.
requirements.txt
View file @
2f918780
tensorflow-g
n
u
==1.15.2
tensorflow-g
p
u
==1.15.2
keras
==2.3.1
scikit-learn
==0.23.1
...
...
src/main.py
View file @
2f918780
import
os
import
time
from
datetime
import
datetime
from
pathlib
import
Path
import
shutil
import
tensorflow
as
tf
from
sklearn.model_selection
import
train_test_split
...
...
@@ -28,6 +30,8 @@ def main():
params
=
{
"feature_columns"
:
all_features
,
"hidden_units"
:
[
32
],
"learning_rate"
:
0.1
}
model_path
=
str
(
Path
(
"~/data/model_tmp/"
)
.
expanduser
())
if
os
.
path
.
exists
(
model_path
):
shutil
.
rmtree
(
model_path
)
model
=
tf
.
estimator
.
Estimator
(
model_fn
=
esmm_model_fn
,
params
=
params
,
model_dir
=
model_path
)
print
(
"train"
)
...
...
@@ -41,8 +45,9 @@ def main():
# predictions = model.predict(input_fn=lambda: esmm_input_fn(test_df, False))
# print(next(iter(predictions)))
test_300
=
test_df
.
sample
(
300
)
time_1
=
time
.
time
()
model_predict
(
test_
df
.
sample
(
300
)
,
save_path
)
model_predict
(
test_
300
,
save_path
)
total_1
=
(
time
.
time
()
-
time_1
)
print
(
"prediction cost {:.5f} s at {}"
.
format
(
total_1
,
datetime
.
now
()))
...
...
src/models/esmm/model.py
View file @
2f918780
...
...
@@ -111,4 +111,5 @@ def model_predict(inputs, model_path):
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
features
))
examples
.
append
(
example
.
SerializeToString
())
predictions
=
predict_fn
({
"examples"
:
examples
})
print
(
predictions
)
# print(predictions)
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