Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
5013ea51
Commit
5013ea51
authored
Jun 26, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create_predict_config for ImageNetModels
parent
decf8310
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
examples/ImageNetModels/imagenet_utils.py
examples/ImageNetModels/imagenet_utils.py
+15
-0
No files found.
examples/ImageNetModels/imagenet_utils.py
View file @
5013ea51
...
@@ -345,6 +345,7 @@ class ImageNetModel(ModelDesc):
...
@@ -345,6 +345,7 @@ class ImageNetModel(ModelDesc):
image
=
tf
.
transpose
(
image
,
[
0
,
3
,
1
,
2
])
image
=
tf
.
transpose
(
image
,
[
0
,
3
,
1
,
2
])
logits
=
self
.
get_logits
(
image
)
logits
=
self
.
get_logits
(
image
)
tf
.
nn
.
softmax
(
logits
,
name
=
'prob'
)
loss
=
ImageNetModel
.
compute_loss_and_error
(
loss
=
ImageNetModel
.
compute_loss_and_error
(
logits
,
label
,
label_smoothing
=
self
.
label_smoothing
)
logits
,
label
,
label_smoothing
=
self
.
label_smoothing
)
...
@@ -423,6 +424,20 @@ class ImageNetModel(ModelDesc):
...
@@ -423,6 +424,20 @@ class ImageNetModel(ModelDesc):
return
loss
return
loss
def
create_predict_config
(
self
,
session_init
):
"""
Returns:
a :class:`PredictConfig` to be used for inference.
The predictor will take inputs and return probabilities.
Examples:
pred = OfflinePredictor(model.create_predict_config(get_model_loader(args.load)))
prob = pred(NCHW_image)[0] # Nx1000 probabilities
"""
return
PredictConfig
(
model
=
self
,
input_names
=
[
'input'
],
output_names
=
[
'prob'
],
session_init
=
session_init
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
argparse
import
argparse
from
tensorpack.dataflow
import
TestDataSpeed
from
tensorpack.dataflow
import
TestDataSpeed
...
...
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