Example #1
0
 def _new_from_args(cls, parsed_args, *args, **params):
     silent = params.pop("_silent", False)
     args_info = _get_info(cls)
     prefix_ = _get_prefix(cls)
     #     params = dict()
     for arg_name, arg_info in args_info.iteritems():
         prefixed_arg_name = prefix_ + arg_name
         if hasattr(parsed_args, prefixed_arg_name):
             val = getattr(parsed_args, prefixed_arg_name)
             if val is not None:
                 if arg_info["mapper"]:
                     params[arg_name] = arg_info["mapper"](val)
                 else:
                     params[arg_name] = val
                 if not silent:
                     print colorize("using argument %s with value %s" % (arg_name, val), "yellow")
     return cls(*args, **params)
Example #2
0
def set_seed(seed):
    global seed_
    seed_ = seed
    import lasagne

    random.seed(seed)
    np.random.seed(seed)
    lasagne.random.set_rng(np.random.RandomState(seed))
    print (colorize("using seed %s" % (str(seed)), "green"))
Example #3
0
File: ext.py Project: cknd/rllab
def set_seed(seed):
    global seed_
    seed_ = seed
    import lasagne
    random.seed(seed)
    np.random.seed(seed)
    lasagne.random.set_rng(np.random.RandomState(seed))
    print((
        colorize(
            'using seed %s' % (str(seed)),
            'green'
        )
    ))
Example #4
0
def set_seed(seed):
    seed %= 4294967294
    global seed_
    seed_ = seed
    import lasagne
    random.seed(seed)
    np.random.seed(seed)
    lasagne.random.set_rng(np.random.RandomState(seed))
    try:
        import tensorflow as tf
        tf.set_random_seed(seed)
    except Exception as e:
        print(e)
    print((colorize('using seed %s' % (str(seed)), 'green')))
Example #5
0
def log(s, with_prefix=True, with_timestamp=True, color=None):
    out = s
    if with_prefix:
        out = _prefix_str + out
    if with_timestamp:
        now = datetime.datetime.now(dateutil.tz.tzlocal())
        timestamp = now.strftime('%Y-%m-%d %H:%M:%S.%f %Z')
        out = "%s | %s" % (timestamp, out)
    if color is not None:
        out = colorize(out, color)
    if not _log_tabular_only:
        # Also log to stdout
        print(out)
        for fd in list(_text_fds.values()):
            fd.write(out + '\n')
            fd.flush()
        sys.stdout.flush()
Example #6
0
def log(s, with_prefix=True, with_timestamp=True, color=None):
    out = s
    if with_prefix:
        out = _prefix_str + out
    if with_timestamp:
        now = datetime.datetime.now(dateutil.tz.tzlocal())
        timestamp = now.strftime('%Y-%m-%d %H:%M:%S.%f %Z')
        out = "%s | %s" % (timestamp, out)
    if color is not None:
        out = colorize(out, color)
    if not _log_tabular_only:
        # Also log to stdout
        print(out)
        for fd in list(_text_fds.values()):
            fd.write(out + '\n')
            fd.flush()
        sys.stdout.flush()
Example #7
0
def set_seed(seed):
    seed %= 4294967294
    global seed_
    seed_ = seed
    import lasagne
    random.seed(seed)
    np.random.seed(seed)
    lasagne.random.set_rng(np.random.RandomState(seed))
    try:
        import tensorflow as tf
        tf.set_random_seed(seed)
    except Exception as e:
        print(e)
    print((
        colorize(
            'using seed %s' % (str(seed)),
            'green'
        )
    ))
Example #8
0
 def _new_from_args(cls, parsed_args, *args, **params):
     silent = params.pop("_silent", False)
     args_info = _get_info(cls)
     prefix_ = _get_prefix(cls)
     #     params = dict()
     for arg_name, arg_info in args_info.items():
         prefixed_arg_name = prefix_ + arg_name
         if hasattr(parsed_args, prefixed_arg_name):
             val = getattr(parsed_args, prefixed_arg_name)
             if val is not None:
                 if arg_info['mapper']:
                     params[arg_name] = arg_info['mapper'](val)
                 else:
                     params[arg_name] = val
                 if not silent:
                     print(
                         colorize(
                             "using argument %s with value %s" %
                             (arg_name, val), "yellow"))
     return cls(*args, **params)
Example #9
0
 def log(self, message, color=None):
     if color is not None:
         message = console.colorize(message, color)
     logger.log(self.log_prefix + message)