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
ce57a145
Commit
ce57a145
authored
Aug 11, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
min/max saver
parent
f74ba9a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
14 deletions
+27
-14
examples/OpenAIGym/README.md
examples/OpenAIGym/README.md
+5
-6
tensorpack/callbacks/common.py
tensorpack/callbacks/common.py
+20
-6
tensorpack/utils/logger.py
tensorpack/utils/logger.py
+2
-2
No files found.
examples/OpenAIGym/README.md
View file @
ce57a145
...
...
@@ -5,10 +5,9 @@
2.
Download models from
[
model zoo
](
https://drive.google.com/open?id=0B9IPQTvr2BBkS0VhX0xmS1c5aFk
)
3.
`ENV=NAME_OF_ENV ./run-atari.py --load "$ENV".tfmodel --env "$ENV"`
<!--
-Models are available for the following gym environments:
-
-+
[
Breakout-v0
](
https://gym.openai.com/envs/Breakout-v0
)
-->
Models are available for the following gym environments:
Note that atari game settings in gym is very different from DeepMind papers, therefore the scores are not comparable.
+
[
Breakout-v0
](
https://gym.openai.com/envs/Breakout-v0
)
+
[
AirRaid-v0
](
https://gym.openai.com/envs/AirRaid-v0
)
Note that atari game settings in gym is more difficult than the settings DeepMind papers, therefore the scores are not comparable.
tensorpack/callbacks/common.py
View file @
ce57a145
...
...
@@ -10,7 +10,7 @@ from .base import Callback
from
..utils
import
*
from
..tfutils.varmanip
import
get_savename_from_varname
__all__
=
[
'ModelSaver'
]
__all__
=
[
'ModelSaver'
,
'MinSaver'
,
'MaxSaver'
]
class
ModelSaver
(
Callback
):
"""
...
...
@@ -81,15 +81,22 @@ because {} will be saved".format(v.name, var_dict[name].name))
logger
.
exception
(
"Exception in ModelSaver.trigger_epoch!"
)
class
MinSaver
(
Callback
):
def
__init__
(
self
,
monitor_stat
):
def
__init__
(
self
,
monitor_stat
,
reverse
=
True
):
self
.
monitor_stat
=
monitor_stat
self
.
reverse
=
reverse
self
.
min
=
None
def
_get_stat
(
self
):
return
self
.
trainer
.
stat_holder
.
get_stat_now
(
self
.
monitor_stat
)
def
_need_save
(
self
):
if
self
.
reverse
:
return
self
.
_get_stat
()
>
self
.
min
else
:
return
self
.
_get_stat
()
<
self
.
min
def
_trigger_epoch
(
self
):
if
self
.
min
is
None
or
self
.
_
get_stat
()
<
self
.
min
:
if
self
.
min
is
None
or
self
.
_
need_save
()
:
self
.
min
=
self
.
_get_stat
()
self
.
_save
()
...
...
@@ -97,10 +104,17 @@ class MinSaver(Callback):
ckpt
=
tf
.
train
.
get_checkpoint_state
(
logger
.
LOG_DIR
)
if
ckpt
is
None
:
raise
RuntimeError
(
"Cannot find a checkpoint state. Do you forget to use ModelSaver
before MinSaver
?"
)
"Cannot find a checkpoint state. Do you forget to use ModelSaver?"
)
path
=
chpt
.
model_checkpoint_path
newname
=
os
.
path
.
join
(
logger
.
LOG_DIR
,
'min_'
+
self
.
monitor_stat
)
newname
=
os
.
path
.
join
(
logger
.
LOG_DIR
,
'max_'
if
self
.
reverse
else
'min_'
+
self
.
monitor_stat
)
shutil
.
copy
(
path
,
newname
)
logger
.
info
(
"Model with minimum {} saved."
.
format
(
self
.
monitor_stat
))
logger
.
info
(
"Model with {} {} saved."
.
format
(
'maximum'
if
self
.
reverse
else
'minimum'
,
self
.
monitor_stat
))
class
MaxSaver
(
MinSaver
):
def
__init__
(
self
,
monitor_stat
):
super
(
MaxSaver
,
self
)
.
__init__
(
monitor_stat
,
True
)
tensorpack/utils/logger.py
View file @
ce57a145
...
...
@@ -67,9 +67,9 @@ def set_logger_dir(dirname, action=None):
if
os
.
path
.
isdir
(
dirname
):
if
not
action
:
_logger
.
warn
(
"""
\
Directory {} exists! Please either backup/delete it, or use a new directory."""
)
Directory {} exists! Please either backup/delete it, or use a new directory."""
.
format
(
dirname
)
)
_logger
.
warn
(
"""
\
If you're resuming from a previous run you can choose to keep it."""
.
format
(
dirname
)
)
If you're resuming from a previous run you can choose to keep it."""
)
_logger
.
info
(
"Select Action: k (keep) / b (backup) / d (delete) / n (new):"
)
while
not
action
:
action
=
input
()
.
lower
()
.
strip
()
...
...
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