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
11c46a71
Commit
11c46a71
authored
May 27, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subproc_call & fix multiprocess sigint problem
parent
b852d652
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
4 deletions
+27
-4
opt-requirements.txt
opt-requirements.txt
+1
-0
tensorpack/dataflow/RL.py
tensorpack/dataflow/RL.py
+2
-2
tensorpack/train/base.py
tensorpack/train/base.py
+7
-2
tensorpack/utils/concurrency.py
tensorpack/utils/concurrency.py
+17
-0
No files found.
opt-requirements.txt
View file @
11c46a71
nltk
h5py
pyzmq
subprocess32
tensorpack/dataflow/RL.py
View file @
11c46a71
...
...
@@ -125,7 +125,7 @@ class ExpReplay(DataFlow, Callback):
end_exploration
=
0.1
,
exploration_epoch_anneal
=
0.002
,
reward_clip
=
None
,
new_experience_per_step
=
1
,
update_frequency
=
1
,
history_len
=
1
):
"""
...
...
@@ -196,7 +196,7 @@ class ExpReplay(DataFlow, Callback):
#view_state(exp[0], exp[1])
yield
self
.
_process_batch
(
batch_exp
)
for
_
in
range
(
self
.
new_experience_per_step
):
for
_
in
range
(
self
.
update_frequency
):
self
.
_populate_exp
()
def
sample_one
(
self
):
...
...
tensorpack/train/base.py
View file @
11c46a71
...
...
@@ -2,12 +2,13 @@
# File: base.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
tensorflow
as
tf
from
abc
import
ABCMeta
,
abstractmethod
import
signal
import
re
from
six.moves
import
range
import
tqdm
import
re
import
tensorflow
as
tf
from
.config
import
TrainConfig
from
..utils
import
*
from
..callbacks
import
StatHolder
...
...
@@ -135,8 +136,12 @@ class Trainer(object):
"""
tf
.
train
.
start_queue_runners
(
sess
=
self
.
sess
,
coord
=
self
.
coord
,
daemon
=
True
,
start
=
True
)
# avoid sigint get handled by other processes
sigint_handler
=
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_IGN
)
for
k
in
self
.
extra_threads_procs
:
k
.
start
()
signal
.
signal
(
signal
.
SIGINT
,
sigint_handler
)
def
process_grads
(
self
,
grads
):
...
...
tensorpack/utils/concurrency.py
View file @
11c46a71
...
...
@@ -8,6 +8,11 @@ import multiprocessing
import
atexit
import
bisect
import
weakref
import
six
if
six
.
PY2
:
import
subprocess32
as
subprocess
else
:
import
subprocess
__all__
=
[
'StoppableThread'
,
'LoopThread'
,
'ensure_proc_terminate'
,
'OrderedResultGatherProc'
,
'OrderedContainer'
,
'DIE'
]
...
...
@@ -69,6 +74,18 @@ def ensure_proc_terminate(proc):
assert
isinstance
(
proc
,
multiprocessing
.
Process
)
atexit
.
register
(
stop_proc_by_weak_ref
,
weakref
.
ref
(
proc
))
def
subproc_call
(
cmd
,
timeout
=
None
):
try
:
output
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
timeout
=
timeout
)
return
output
except
subprocess
.
TimeoutExpired
as
e
:
logger
.
warn
(
"Timeout in evaluation!"
)
logger
.
warn
(
e
.
output
)
except
subprocess
.
CalledProcessError
as
e
:
logger
.
warn
(
"Evaluation script failed: {}"
.
format
(
e
.
returncode
))
logger
.
warn
(
e
.
output
)
class
OrderedContainer
(
object
):
"""
...
...
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