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
b506eb0a
Commit
b506eb0a
authored
Feb 04, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix prefetch
parent
477c4446
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
tensorpack/dataflow/prefetch.py
tensorpack/dataflow/prefetch.py
+11
-9
tensorpack/models/image_sample.py
tensorpack/models/image_sample.py
+4
-4
No files found.
tensorpack/dataflow/prefetch.py
View file @
b506eb0a
...
...
@@ -9,24 +9,24 @@ import multiprocessing
__all__
=
[
'PrefetchData'
]
class
Sentinel
:
pass
class
PrefetchProcess
(
multiprocessing
.
Process
):
def
__init__
(
self
,
ds
,
queue_size
):
super
(
PrefetchProcess
,
self
)
.
__init__
()
self
.
ds
=
ds
self
.
queue
=
multiprocessing
.
Queue
(
queue_size
)
class
Sentinel
:
pass
self
.
sentinel
=
Sentinel
()
def
run
(
self
):
for
dp
in
self
.
ds
.
get_data
():
self
.
queue
.
put
(
dp
)
self
.
queue
.
put
(
self
.
sentinel
)
self
.
queue
.
put
(
Sentinel
()
)
def
get_data
(
self
):
while
True
:
ret
=
self
.
queue
.
get
()
if
ret
is
self
.
sentinel
:
if
isinstance
(
ret
,
Sentinel
)
:
return
yield
ret
...
...
@@ -43,8 +43,10 @@ class PrefetchData(DataFlow):
worker
=
PrefetchProcess
(
self
.
ds
,
self
.
nr_prefetch
)
# TODO register terminate function
worker
.
start
()
for
dp
in
worker
.
get_data
():
yield
dp
worker
.
join
()
worker
.
terminate
()
try
:
for
dp
in
worker
.
get_data
():
yield
dp
finally
:
worker
.
join
()
worker
.
terminate
()
tensorpack/models/image_sample.py
View file @
b506eb0a
...
...
@@ -71,10 +71,10 @@ def ImageSample(template, mapping):
tf
.
reduce_max
(
diff
),
diff
],
summarize
=
50
)
return
sample
(
template
,
lcoor
)
*
neg_diffx
*
neg_diffy
+
\
sample
(
template
,
ucoor
)
*
diffx
*
diffy
+
\
sample
(
template
,
lyux
)
*
neg_diffy
*
diffx
+
\
sample
(
template
,
uylx
)
*
diffy
*
neg_diffx
return
tf
.
add_n
([
sample
(
template
,
lcoor
)
*
neg_diffx
*
neg_diffy
,
sample
(
template
,
ucoor
)
*
diffx
*
diffy
,
sample
(
template
,
lyux
)
*
neg_diffy
*
diffx
,
sample
(
template
,
uylx
)
*
diffy
*
neg_diffx
],
name
=
'sampled'
)
from
_test
import
TestModel
class
TestSample
(
TestModel
):
...
...
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