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): ...@@ -52,7 +52,7 @@ class HyperParam(object):
class GraphVarParam(HyperParam): 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=[]): def __init__(self, name, shape=[]):
""" """
...@@ -91,7 +91,7 @@ class ObjAttrParam(HyperParam): ...@@ -91,7 +91,7 @@ class ObjAttrParam(HyperParam):
Args: Args:
obj: the object obj: the object
attrname (str): the attribute 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.obj = obj
self.attrname = attrname self.attrname = attrname
...@@ -179,10 +179,9 @@ class HumanHyperParamSetter(HyperParamSetter): ...@@ -179,10 +179,9 @@ class HumanHyperParamSetter(HyperParamSetter):
""" """
Args: Args:
param: same as in :class:`HyperParamSetter`. param: same as in :class:`HyperParamSetter`.
file_name(str): a file containing the value of the variable. file_name(str): a file containing the new value of the parameter.
Each line in the file is a k:v pair, where k is Each line in the file is a ``k:v`` pair, for example, ``learning_rate:1e-4``.
param.readable_name, and v is the value. If the pair is not found, If the pair is not found, the param will not be changed.
the param will not be changed.
""" """
super(HumanHyperParamSetter, self).__init__(param) super(HumanHyperParamSetter, self).__init__(param)
self.file_name = os.path.join(logger.LOG_DIR, file_name) self.file_name = os.path.join(logger.LOG_DIR, file_name)
......
...@@ -79,7 +79,7 @@ def set_logger_dir(dirname, action=None): ...@@ -79,7 +79,7 @@ def set_logger_dir(dirname, action=None):
Args: Args:
dirname(str): log directory 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 global LOG_DIR, _FILE_HANDLER
if _FILE_HANDLER: if _FILE_HANDLER:
...@@ -89,10 +89,10 @@ def set_logger_dir(dirname, action=None): ...@@ -89,10 +89,10 @@ def set_logger_dir(dirname, action=None):
if os.path.isdir(dirname): if os.path.isdir(dirname):
if not action: if not action:
_logger.warn("""\ _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("""\ _logger.warn("""\
If you're resuming from a previous run you can choose to keep it.""") 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: while not action:
action = input().lower().strip() action = input().lower().strip()
act = action act = action
...@@ -107,6 +107,8 @@ If you're resuming from a previous run you can choose to keep it.""") ...@@ -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 info("Use a new log directory {}".format(dirname)) # noqa: F821
elif act == 'k': elif act == 'k':
pass pass
elif act == 'q':
sys.exit()
else: else:
raise ValueError("Unknown action: {}".format(act)) raise ValueError("Unknown action: {}".format(act))
LOG_DIR = dirname 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