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
04b52d20
Commit
04b52d20
authored
Dec 21, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix InferenceRunner for zero input size (#565)
parent
db36b929
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
tensorpack/callbacks/inference.py
tensorpack/callbacks/inference.py
+3
-2
tensorpack/callbacks/inference_runner.py
tensorpack/callbacks/inference_runner.py
+6
-2
No files found.
tensorpack/callbacks/inference.py
View file @
04b52d20
...
...
@@ -120,6 +120,7 @@ class ScalarStats(Inferencer):
self
.
stats
.
append
(
output
)
def
_after_inference
(
self
):
if
len
(
self
.
stats
):
self
.
stats
=
np
.
mean
(
self
.
stats
,
axis
=
0
)
assert
len
(
self
.
stats
)
==
len
(
self
.
names
)
...
...
tensorpack/callbacks/inference_runner.py
View file @
04b52d20
...
...
@@ -3,6 +3,7 @@
# File: inference_runner.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
sys
import
tensorflow
as
tf
from
tensorflow.python.training.monitored_session
\
import
_HookedSession
as
HookedSession
...
...
@@ -158,9 +159,12 @@ class InferenceRunner(InferenceRunnerBase):
# iterate over the data, and run the hooked session
self
.
_input_source
.
reset_state
()
with
_inference_context
():
for
_
in
tqdm
.
trange
(
self
.
_size
,
**
get_tqdm_kwargs
()):
with
_inference_context
(),
\
tqdm
.
tqdm
(
total
=
self
.
_size
,
**
get_tqdm_kwargs
())
as
pbar
:
num_itr
=
self
.
_size
if
self
.
_size
>
0
else
sys
.
maxsize
for
_
in
range
(
num_itr
):
self
.
_hooked_sess
.
run
(
fetches
=
[])
pbar
.
update
()
for
inf
in
self
.
infs
:
inf
.
trigger_epoch
()
...
...
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