Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
serviceRec
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
郭羽
serviceRec
Commits
feda168b
Commit
feda168b
authored
3 years ago
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型上线
parent
f00d863e
master
No related merge requests found
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
predict_tfserving.py
train/predict_tfserving.py
+0
-0
predict_tfserving_grpc.py
train/predict_tfserving_grpc.py
+5
-4
train_service_sk_tf2_distibute.py
train/train_service_sk_tf2_distibute.py
+1
-1
No files found.
train/predict_tfserving.py
View file @
feda168b
This diff is collapsed.
Click to expand it.
train/predict_tfserving_grpc.py
View file @
feda168b
...
@@ -17,7 +17,8 @@ from tensorflow_serving.apis import predict_pb2
...
@@ -17,7 +17,8 @@ from tensorflow_serving.apis import predict_pb2
from
tensorflow_serving.apis
import
prediction_service_pb2_grpc
from
tensorflow_serving.apis
import
prediction_service_pb2_grpc
import
grpc
import
grpc
tf
.
app
.
flags
.
DEFINE_string
(
'server'
,
'localhost:8502'
,
'PredictionService host:port'
)
# tf.app.flags.DEFINE_string('server', 'localhost:8502', 'PredictionService host:port')
tf
.
app
.
flags
.
DEFINE_string
(
'server'
,
'tensorserving-sk.paas-develop.env:8090'
,
'PredictionService host:port'
)
FLAGS
=
tf
.
app
.
flags
.
FLAGS
FLAGS
=
tf
.
app
.
flags
.
FLAGS
def
prediction
():
def
prediction
():
...
@@ -25,9 +26,9 @@ def prediction():
...
@@ -25,9 +26,9 @@ def prediction():
channel
=
grpc
.
insecure_channel
(
FLAGS
.
server
,
options
=
options
)
channel
=
grpc
.
insecure_channel
(
FLAGS
.
server
,
options
=
options
)
stub
=
prediction_service_pb2_grpc
.
PredictionServiceStub
(
channel
)
stub
=
prediction_service_pb2_grpc
.
PredictionServiceStub
(
channel
)
request
=
predict_pb2
.
PredictRequest
()
request
=
predict_pb2
.
PredictRequest
()
request
.
model_spec
.
name
=
'
wide_deep
'
#对应上图第一个方框
request
.
model_spec
.
name
=
'
service
'
#对应上图第一个方框
request
.
model_spec
.
signature_name
=
'regression'
#对应上图第二个方框with open('/Users/edz/software/Recommend/train_samples.csv', 'r') as f:
request
.
model_spec
.
signature_name
=
'regression'
#对应上图第二个方框with open('/Users/edz/software/Recommend/train_samples.csv', 'r') as f:
for
_
in
range
(
20
):
for
_
in
range
(
1
):
with
open
(
'/Users/edz/software/Recommend/train_samples.csv'
,
'r'
)
as
f
:
with
open
(
'/Users/edz/software/Recommend/train_samples.csv'
,
'r'
)
as
f
:
count
=
0
count
=
0
...
@@ -92,7 +93,7 @@ def prediction():
...
@@ -92,7 +93,7 @@ def prediction():
examples
.
append
(
tf_serialized
)
examples
.
append
(
tf_serialized
)
count
+=
1
count
+=
1
if
count
==
1
000
:
if
count
==
1
:
break
break
start
=
time
.
time
()
start
=
time
.
time
()
# request.inputs['examples'].CopyFrom(tf.make_tensor_proto(examples)) # in对应上图第三个方框,为模型的输入Name
# request.inputs['examples'].CopyFrom(tf.make_tensor_proto(examples)) # in对应上图第三个方框,为模型的输入Name
...
...
This diff is collapsed.
Click to expand it.
train/train_service_sk_tf2_distibute.py
View file @
feda168b
...
@@ -238,7 +238,7 @@ early_stopping = tf.estimator.experimental.stop_if_no_increase_hook(wideAndDeepM
...
@@ -238,7 +238,7 @@ early_stopping = tf.estimator.experimental.stop_if_no_increase_hook(wideAndDeepM
hooks
=
[
early_stopping
]
hooks
=
[
early_stopping
]
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
input_fn
(
DATA_DIR
+
'train_samples.csv'
,
1
00
,
True
,
2048
),
hooks
=
hooks
)
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
input_fn
(
DATA_DIR
+
'train_samples.csv'
,
1
,
True
,
2048
),
hooks
=
hooks
)
serving_feature_spec
=
tf
.
feature_column
.
make_parse_example_spec
(
serving_feature_spec
=
tf
.
feature_column
.
make_parse_example_spec
(
linear_feature_columns
+
dnn_feature_columns
)
linear_feature_columns
+
dnn_feature_columns
)
...
...
This diff is collapsed.
Click to expand it.
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