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
5b310290
You need to sign in or sign up before continuing.
Commit
5b310290
authored
Aug 06, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
infinite option in FeedInput
parent
3745b4d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
tensorpack/callbacks/inference_runner.py
tensorpack/callbacks/inference_runner.py
+9
-3
tensorpack/graph_builder/input_source.py
tensorpack/graph_builder/input_source.py
+8
-4
No files found.
tensorpack/callbacks/inference_runner.py
View file @
5b310290
...
@@ -115,8 +115,14 @@ class InferenceRunnerBase(Callback):
...
@@ -115,8 +115,14 @@ class InferenceRunnerBase(Callback):
# iterate over the data, and run the hooked session
# iterate over the data, and run the hooked session
self
.
_input_source
.
reset_state
()
self
.
_input_source
.
reset_state
()
for
_
in
tqdm
.
trange
(
self
.
_size
,
**
get_tqdm_kwargs
()):
msg
=
"You might need to check your input implementation."
self
.
_hooked_sess
.
run
(
fetches
=
[])
try
:
for
_
in
tqdm
.
trange
(
self
.
_size
,
**
get_tqdm_kwargs
()):
self
.
_hooked_sess
.
run
(
fetches
=
[])
except
StopIteration
:
raise
RuntimeError
(
"[InferenceRunner] input stopped before reaching its size()! "
+
msg
)
summary_inferencer
(
self
.
trainer
,
self
.
infs
)
summary_inferencer
(
self
.
trainer
,
self
.
infs
)
...
@@ -133,7 +139,7 @@ class InferenceRunner(InferenceRunnerBase):
...
@@ -133,7 +139,7 @@ class InferenceRunner(InferenceRunnerBase):
infs (list): a list of :class:`Inferencer` instances.
infs (list): a list of :class:`Inferencer` instances.
"""
"""
if
isinstance
(
input
,
DataFlow
):
if
isinstance
(
input
,
DataFlow
):
input
=
FeedInput
(
input
)
input
=
FeedInput
(
input
,
infinite
=
False
)
assert
isinstance
(
input
,
InputSource
),
input
assert
isinstance
(
input
,
InputSource
),
input
if
isinstance
(
input
,
FeedfreeInput
):
# TODO support other input
if
isinstance
(
input
,
FeedfreeInput
):
# TODO support other input
assert
isinstance
(
input
,
TensorInput
),
"InferenceRunner only accepts TensorInput or FeedInput!"
assert
isinstance
(
input
,
TensorInput
),
"InferenceRunner only accepts TensorInput or FeedInput!"
...
...
tensorpack/graph_builder/input_source.py
View file @
5b310290
...
@@ -65,22 +65,26 @@ class FeedInput(InputSource):
...
@@ -65,22 +65,26 @@ class FeedInput(InputSource):
self
.
_ds
.
reset_state
()
self
.
_ds
.
reset_state
()
self
.
_itr
=
self
.
_ds
.
get_data
()
self
.
_itr
=
self
.
_ds
.
get_data
()
def
__init__
(
self
,
ds
):
def
__init__
(
self
,
ds
,
infinite
=
True
):
"""
"""
Args:
Args:
ds (DataFlow): the input DataFlow.
ds (DataFlow): the input DataFlow.
infinite (bool): When set to False, will raise StopIteration when
ds is exhausted.
"""
"""
assert
isinstance
(
ds
,
DataFlow
),
ds
assert
isinstance
(
ds
,
DataFlow
),
ds
self
.
ds
=
ds
self
.
ds
=
ds
# TODO avoid infinite repeat, to allow accurate size handling
if
infinite
:
self
.
_repeat_ds
=
RepeatedData
(
self
.
ds
,
-
1
)
self
.
_iter_ds
=
RepeatedData
(
self
.
ds
,
-
1
)
else
:
self
.
_iter_ds
=
self
.
ds
def
_size
(
self
):
def
_size
(
self
):
return
self
.
ds
.
size
()
return
self
.
ds
.
size
()
def
_setup
(
self
,
inputs
):
def
_setup
(
self
,
inputs
):
self
.
_all_placehdrs
=
[
v
.
build_placeholder
(
prefix
=
''
)
for
v
in
inputs
]
self
.
_all_placehdrs
=
[
v
.
build_placeholder
(
prefix
=
''
)
for
v
in
inputs
]
self
.
_cb
=
self
.
_FeedCallback
(
self
.
_
repeat
_ds
,
self
.
_all_placehdrs
)
self
.
_cb
=
self
.
_FeedCallback
(
self
.
_
iter
_ds
,
self
.
_all_placehdrs
)
self
.
reset_state
()
self
.
reset_state
()
def
_get_input_tensors
(
self
):
def
_get_input_tensors
(
self
):
...
...
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