def main_wrap(main_fn, logfile_name=None, **kwds): if logfile_name is None: # if logfile_name not set, derive it from main_fn fn = main_fn.func_code.co_filename logfile_name = os.path.splitext(os.path.basename(fn))[0] setup_once(logfile_name) try: # we might be running under python with no keras/numpy support init(**kwds) except ImportError as exc: log.warning("ImportError: %s" % exc) try: if main_fn.func_code.co_argcount == 0: return main_fn() else: return main_fn(sys.argv[1:]) except Exception as exc: print exc _, _, tb = sys.exc_info() traceback.print_exc() pdb.post_mortem(tb)
def main(): from ggpzero.util.keras import init init() args = sys.argv[1:] port = int(args[0]) conf = compete if args[1] == "-fpu": conf.name += "_fpu" conf.fpu_prior_discount = 0.25 args = args[1:] generation = args[1] conf.generation = generation # conf = templates.puct_config_template(generation, config_name) if len(args) >= 2: playouts_multiplier = int(args[2]) if playouts_multiplier == 0: conf.playouts_per_iteration = 1 else: conf.playouts_per_iteration *= playouts_multiplier player = PUCTPlayer(conf=conf) from ggplib.play import play_runner play_runner(player, port)
def start_server_factory(): def dump(): print "$ python server.py -c <game> <generation_name>" print "$ python server.py <config_file>" sys.exit(1) if len(sys.argv) != 2 and len(sys.argv) != 4: dump() if len(sys.argv) == 4: if sys.argv[1] != "-c": dump() game, generation_prefix = sys.argv[2], sys.argv[3] conf = templates.server_config_template(game, generation_prefix, 1) print attrutil.attr_to_json(conf, pretty=True) else: if sys.argv[1] == "-c": dump() from ggplib.util.init import setup_once setup_once("server") from ggpzero.util.keras import init init() filename = sys.argv[1] assert os.path.exists(filename) ServerBroker(filename) reactor.run()
def setup(log_name_base=None): if log_name_base is not None: setup_once(log_name_base=log_name_base) else: setup_once(log_name_base=log_name_base) init() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR)
def setup(): from ggplib.util.init import setup_once setup_once() from ggpzero.util.keras import init init() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR)
def start_worker_factory(): from ggplib.util.init import setup_once setup_once("worker") from ggpzero.util.keras import init init() broker = Worker(sys.argv[1]) broker.start()
def setup(): import tensorflow as tf from ggplib.util.init import setup_once setup_once() from ggpzero.util.keras import init init() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR) import numpy as np np.set_printoptions(threshold=100000)
def setup(): # set up ggplib setup_once() # ensure we have database with ggplib lookup.get_database() # initialise keras/tf keras.init() # just ensures we have the manager ready get_manager() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR) np.set_printoptions(threshold=100000, precision=2)
def start_worker_factory(): if len(sys.argv) != 2: print "$ python worker.py -c" print "$ python server.py <config_file>" sys.exit(1) if sys.argv[1] == "-c": print attrutil.attr_to_json(default_conf(), pretty=True) return from ggplib.util.init import setup_once setup_once("worker") from ggpzero.util.keras import init init() broker = Worker(sys.argv[1]) broker.start()
def setup(): import tensorflow as tf from ggplib.util.init import setup_once setup_once() from ggpzero.util.keras import init init() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR) import numpy as np np.set_printoptions(threshold=100000) man = get_manager() if not man.can_load(GAME, RANDOM_GEN): network = man.create_new_network(GAME) man.save_network(network, RANDOM_GEN)
def setup(): # set up ggplib setup_once() # ensure we have database with ggplib lookup.get_database() # initialise keras/tf keras.init() # just ensures we have the manager ready get_manager() os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.logging.set_verbosity(tf.logging.ERROR) np.set_printoptions(threshold=100000) from gzero_games.ggphack import addgame addgame.install_games()
def start_server_factory(): from ggplib.util.init import setup_once setup_once("server") from ggpzero.util.keras import init init() if sys.argv[1] == "-c": game, generation_prefix = sys.argv[2], sys.argv[3] num_prev_states = int(sys.argv[4]) filename = sys.argv[5] conf = templates.server_config_template(game, generation_prefix, num_prev_states) ServerBroker(filename, conf) else: filename = sys.argv[1] assert os.path.exists(filename) ServerBroker(filename) reactor.run()
def setup(): from ggplib.util.init import setup_once setup_once() from ggpzero.util.keras import init init()