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
2b4f7b14
You need to sign in or sign up before continuing.
Commit
2b4f7b14
authored
May 05, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
play_n_episodes for gym submission
parent
4414d3ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
17 deletions
+21
-17
examples/A3C-Gym/train-atari.py
examples/A3C-Gym/train-atari.py
+6
-14
examples/DeepQNetwork/DQN.py
examples/DeepQNetwork/DQN.py
+4
-1
examples/DeepQNetwork/DQNModel.py
examples/DeepQNetwork/DQNModel.py
+0
-1
examples/DeepQNetwork/common.py
examples/DeepQNetwork/common.py
+9
-0
tests/dev/git-hooks/pre-commit
tests/dev/git-hooks/pre-commit
+2
-1
No files found.
examples/A3C-Gym/train-atari.py
View file @
2b4f7b14
...
...
@@ -28,7 +28,8 @@ from tensorpack.tfutils.gradproc import MapGradient, SummaryGradient
from
tensorpack.RL
import
*
from
simulator
import
*
import
common
from
common
import
(
play_model
,
Evaluator
,
eval_model_multithread
,
play_one_episode
)
from
common
import
(
play_model
,
Evaluator
,
eval_model_multithread
,
play_one_episode
,
play_n_episodes
)
if
six
.
PY3
:
from
concurrent
import
futures
...
...
@@ -238,18 +239,6 @@ def get_config():
)
def
run_submission
(
cfg
,
output
,
nr
):
player
=
get_player
(
train
=
False
,
dumpdir
=
output
)
predfunc
=
OfflinePredictor
(
cfg
)
logger
.
info
(
"Start evaluation: "
)
for
k
in
range
(
nr
):
if
k
!=
0
:
player
.
restart_episode
()
score
=
play_one_episode
(
player
,
predfunc
)
print
(
"Score:"
,
score
)
# gym.upload(output, api_key='xxx')
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--gpu'
,
help
=
'comma separated list of GPU(s) to use.'
)
...
...
@@ -283,7 +272,10 @@ if __name__ == '__main__':
elif
args
.
task
==
'eval'
:
eval_model_multithread
(
cfg
,
args
.
episode
,
get_player
)
elif
args
.
task
==
'gen_submit'
:
run_submission
(
cfg
,
args
.
output
,
args
.
episode
)
play_n_episodes
(
get_player
(
train
=
False
,
dumpdir
=
args
.
output
),
OfflinePredictor
(
cfg
),
args
.
episode
)
# gym.upload(output, api_key='xxx')
else
:
nr_gpu
=
get_nr_gpu
()
if
nr_gpu
>
0
:
...
...
examples/DeepQNetwork/DQN.py
View file @
2b4f7b14
...
...
@@ -62,6 +62,9 @@ def get_player(viz=False, train=False):
class
Model
(
DQNModel
):
def
__init__
(
self
):
super
(
Model
,
self
)
.
__init__
(
IMAGE_SIZE
,
CHANNEL
,
METHOD
,
NUM_ACTIONS
,
GAMMA
)
def
_get_DQN_prediction
(
self
,
image
):
""" image: [0,255]"""
image
=
image
/
255.0
...
...
@@ -95,7 +98,7 @@ class Model(DQNModel):
def
get_config
():
logger
.
auto_set_dir
()
M
=
Model
(
IMAGE_SIZE
,
CHANNEL
,
METHOD
,
NUM_ACTIONS
,
GAMMA
)
M
=
Model
()
expreplay
=
ExpReplay
(
predictor_io_names
=
([
'state'
],
[
'Qvalue'
]),
player
=
get_player
(
train
=
True
),
...
...
examples/DeepQNetwork/DQNModel.py
View file @
2b4f7b14
...
...
@@ -93,4 +93,3 @@ class Model(ModelDesc):
logger
.
info
(
"{} <- {}"
.
format
(
target_name
,
new_name
))
ops
.
append
(
v
.
assign
(
G
.
get_tensor_by_name
(
new_name
+
':0'
)))
return
tf
.
group
(
*
ops
,
name
=
'update_target_network'
)
examples/DeepQNetwork/common.py
View file @
2b4f7b14
...
...
@@ -112,3 +112,12 @@ class Evaluator(Triggerable):
self
.
eval_episode
=
int
(
self
.
eval_episode
*
0.94
)
self
.
trainer
.
monitors
.
put
(
'mean_score'
,
mean
)
self
.
trainer
.
monitors
.
put
(
'max_score'
,
max
)
def
play_n_episodes
(
player
,
predfunc
,
nr
):
logger
.
info
(
"Start evaluation: "
)
for
k
in
range
(
nr
):
if
k
!=
0
:
player
.
restart_episode
()
score
=
play_one_episode
(
player
,
predfunc
)
print
(
"Score:"
,
score
)
tests/dev/git-hooks/pre-commit
View file @
2b4f7b14
...
...
@@ -5,5 +5,6 @@ cd examples
GIT_ARG
=
"--git-dir ../.git --work-tree .."
# find out modified python files
MOD
=
$(
git
$GIT_ARG
status
-s
|
grep
-E
'\.py$'
|
grep
-E
'^\b+M\b+'
|
cut
-c
4-
)
MOD
=
$(
git
$GIT_ARG
status
-s
|
grep
-E
'\.py$'
|
grep
-E
'^ *M|^ *A '
|
cut
-c
4-
)
# git $GIT_ARG status -s | grep -E '\.py$'
flake8
$MOD
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