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)
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"))
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' ) ))
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')))
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()
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' ) ))
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)
def log(self, message, color=None): if color is not None: message = console.colorize(message, color) logger.log(self.log_prefix + message)