Esempio n. 1
0
    def __init__(self,
                 config_path=None,
                 config_section=None,
                 database_path=None):
        if not config_path:
            config_path = os.environ.get("CONFIG_PATH", "cfg/config.json")

        if not config_section:
            config_section = os.environ.get("CONFIG_SECTION", "default")

        if not database_path:
            database_path = os.environ.get("DATABASE_PATH", "db/database.db")

        self.config = Config(config_path, config_section)
        self.database = Database(database_path)
Esempio n. 2
0
    def __init__(self,
                 config_path=None,
                 config_section=None,
                 database_path=None):
        if not config_path:
            config_path = os.environ.get("CONFIG_PATH", "cfg/config.json")

        if not config_section:
            config_section = os.environ.get("CONFIG_SECTION", "default")

        if not database_path:
            database_path = os.environ.get("DATABASE_PATH", "db/database.db")

        self.config = Config(config_path, config_section)
        self.database = Database(database_path)
        self.latest_comic_number = int(
            self.get_latest_comic())  # to initialize to latest comic.
Esempio n. 3
0
 def setUp(self):
     self.config = Config("test_config.json", "test")
Esempio n. 4
0
 def __init__(self,
              config_name="config.json",
              config_section="default",
              database_name="database.db"):
     self.config = Config(config_name, config_section)
     self.database = Database(database_name)
Esempio n. 5
0
    config_path = "cfg/" + sys.argv[1]
    if not os.path.exists(config_path):
        raise Exception(
            "Config file not found in cfg/ directory. Usage: `python train.py <FILENAME>.yaml`"
        )
    return config_path


if __name__ == "__main__":
    args = get_args()
    training_directory, log_file, timestamp = create_training_contents()
    config(log_file)
    config_path = get_config_file()
    copyfile(config_path, training_directory + timestamp + ".yaml")

    try:
        set_seeds(0)
        algorithm = NES(training_directory, Config(config_path).config)
        print("Running NES Algorithm...")
        print("Check {} for progress".format(log_file))
        algorithm.run()
    except KeyboardInterrupt:
        if args.d:
            print("\nDeleted: {}".format(training_directory))
            rmtree(training_directory)
        sys.exit(1)

    if args.d:
        print("\nDeleted Training Folder: {}".format(training_directory))
        rmtree(training_directory)
Esempio n. 6
0
	config_path = "cfg/" + sys.argv[1]
	if not os.path.exists(config_path):
		raise Exception("Config file not found in cfg/ directory. Usage: `python train.py <FILENAME>.yaml`")
	return config_path

if __name__ == "__main__":

	args = get_args()
	training_directory, log_file, timestamp = create_training_contents()
	config(log_file)
	config_path = get_config_file()
	copyfile(config_path, training_directory + timestamp + ".yaml")

	try:
		set_seeds(0)
		config = Config(config_path).config
		algorithms = {"CMA_ES": CMA_ES, "ES": ES, "NES": NES, "EntES": EntES}
		algorithm = algorithms[config['algorithm']](training_directory, config)
		print("Running %s Algorithm..." % (config['algorithm']))
		print("Check {} for progress".format(log_file))
		algorithm.run()
		# set_seeds(0)
		# config = Config(config_path).config
		# algorithms = {"CMA_ES": CMA_ES, "ES": ES, "NES": NES, "EntES": EntES}
		# algorithm = algorithms[config['algorithm']](training_directory, config)
		# print("Running %s Algorithm..." % (config['algorithm']))
		# print("Check {} for progress".format(log_file))
		# cma_master, cma_popl = CMA_ES(training_directory, config).run()
		# es_master, es_popl = ES(training_directory, config).run()
		# plt.title("CMA-ES vs ES: Master Rewards")
		# plt.plot(range(len(cma_master)), cma_master, color="red", label="CMA-ES")
Esempio n. 7
0
 def setUp(self):
     self.config = Config(config_name="test_config.json", section="test")