Commit 789f082f authored by Yuxin Wu's avatar Yuxin Wu

docs about HumanHyperParamSetter; add 'q' action to avoid getting stuck

parent 900a7eb0
......@@ -52,7 +52,7 @@ class HyperParam(object):
class GraphVarParam(HyperParam):
""" A variable in the graph (e.g. learning_rate) can be a hyperparam"""
""" A variable in the graph (e.g. learning_rate) can be a hyperparam."""
def __init__(self, name, shape=[]):
"""
......@@ -91,7 +91,7 @@ class ObjAttrParam(HyperParam):
Args:
obj: the object
attrname (str): the attribute
readable_name(str): The name to display. Defaults to be ``attrname``.
readable_name(str): The name to display and set with. Defaults to be ``attrname``.
"""
self.obj = obj
self.attrname = attrname
......@@ -179,10 +179,9 @@ class HumanHyperParamSetter(HyperParamSetter):
"""
Args:
param: same as in :class:`HyperParamSetter`.
file_name(str): a file containing the value of the variable.
Each line in the file is a k:v pair, where k is
param.readable_name, and v is the value. If the pair is not found,
the param will not be changed.
file_name(str): a file containing the new value of the parameter.
Each line in the file is a ``k:v`` pair, for example, ``learning_rate:1e-4``.
If the pair is not found, the param will not be changed.
"""
super(HumanHyperParamSetter, self).__init__(param)
self.file_name = os.path.join(logger.LOG_DIR, file_name)
......
......@@ -79,7 +79,7 @@ def set_logger_dir(dirname, action=None):
Args:
dirname(str): log directory
action(str): an action of ("k","b","d","n") to be performed. Will ask user by default.
action(str): an action of ("k","b","d","n","q") to be performed. Will ask user by default.
"""
global LOG_DIR, _FILE_HANDLER
if _FILE_HANDLER:
......@@ -89,10 +89,10 @@ 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.""".format(dirname))
Log 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.""")
_logger.info("Select Action: k (keep) / b (backup) / d (delete) / n (new):")
_logger.info("Select Action: k (keep) / b (backup) / d (delete) / n (new) / q (quit):")
while not action:
action = input().lower().strip()
act = action
......@@ -107,6 +107,8 @@ If you're resuming from a previous run you can choose to keep it.""")
info("Use a new log directory {}".format(dirname)) # noqa: F821
elif act == 'k':
pass
elif act == 'q':
sys.exit()
else:
raise ValueError("Unknown action: {}".format(act))
LOG_DIR = dirname
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment