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
335d6c28
Commit
335d6c28
authored
Jun 08, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
faster serialize
parent
126fd26a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
13 deletions
+12
-13
tensorpack/RL/simulator.py
tensorpack/RL/simulator.py
+3
-5
tensorpack/predict/concurrency.py
tensorpack/predict/concurrency.py
+1
-0
tensorpack/utils/serialize.py
tensorpack/utils/serialize.py
+8
-8
No files found.
tensorpack/RL/simulator.py
View file @
335d6c28
...
...
@@ -43,7 +43,7 @@ class SimulatorProcess(multiprocessing.Process):
context
=
zmq
.
Context
()
c2s_socket
=
context
.
socket
(
zmq
.
DEALER
)
c2s_socket
.
identity
=
'simulator-{}'
.
format
(
self
.
idx
)
#
c2s_socket.set_hwm(2)
c2s_socket
.
set_hwm
(
2
)
c2s_socket
.
connect
(
self
.
c2s
)
s2c_socket
=
context
.
socket
(
zmq
.
DEALER
)
...
...
@@ -54,8 +54,7 @@ class SimulatorProcess(multiprocessing.Process):
#cnt = 0
while
True
:
state
=
player
.
current_state
()
#c2s_socket.send(dumps(state), copy=False)
c2s_socket
.
send
(
'h'
)
c2s_socket
.
send
(
dumps
(
state
),
copy
=
False
)
#with total_timer('client recv_action'):
data
=
s2c_socket
.
recv
(
copy
=
False
)
action
=
loads
(
data
)
...
...
@@ -126,8 +125,7 @@ class SimulatorMaster(threading.Thread):
client
=
self
.
clients
[
ident
]
client
.
protocol_state
=
1
-
client
.
protocol_state
# first flip the state
if
not
client
.
protocol_state
==
0
:
# state-action
#state = loads(msg)
state
=
np
.
zeros
((
84
,
84
,
4
),
dtype
=
'float32'
)
state
=
loads
(
msg
)
self
.
_on_state
(
state
,
ident
)
else
:
# reward-response
reward
,
isOver
=
loads
(
msg
)
...
...
tensorpack/predict/concurrency.py
View file @
335d6c28
...
...
@@ -112,6 +112,7 @@ class PredictorWorkerThread(threading.Thread):
batched
,
futures
=
fetch
()
#print "batched size: ", len(batched), "queuesize: ", self.queue.qsize()
outputs
=
self
.
func
([
batched
])
# debug, for speed testing
#if self.xxx is None:
#outputs = self.func([batched])
#self.xxx = outputs
...
...
tensorpack/utils/serialize.py
View file @
335d6c28
...
...
@@ -3,17 +3,17 @@
# File: serialize.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
#
import msgpack
#
import msgpack_numpy
#
msgpack_numpy.patch()
import
dill
import
msgpack
import
msgpack_numpy
msgpack_numpy
.
patch
()
#
import dill
__all__
=
[
'loads'
,
'dumps'
]
def
dumps
(
obj
):
return
dill
.
dumps
(
obj
)
#
return msgpack.dumps(obj, use_bin_type=True)
#
return dill.dumps(obj)
return
msgpack
.
dumps
(
obj
,
use_bin_type
=
True
)
def
loads
(
buf
):
return
dill
.
loads
(
buf
)
#
return msgpack.loads(buf)
#
return dill.loads(buf)
return
msgpack
.
loads
(
buf
)
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