def _make_env(config_file, host, port): config = load_config(config_file) if config['typename'] == 'RemoteEnv': if port: config['args']['port'] = port if host: config['args']['host'] = host return get_env(config['typename'])(**config.get('args', {}))
def _build_network(model_filepath, optimizer_filepath, initial_parameter): _LG.info('Building Q networks') dql = DeepQLearning( q_learning_config={ 'discount_rate': 0.99, 'min_reward': -1.0, 'max_reward': 1.0, }, optimizer_config=load_config(optimizer_filepath), ) model_def = _gen_model_def(model_filepath) dql.build(model_def, initial_parameter) _LG.info('Syncing models') dql.sync_network() return dql
def get_model_config(filepath, **parameters): """Load model configurations from file Parameters ---------- model_name : str Model name or path to YAML file parameters Parameter for model config Returns ------- JSON-compatible object Model configuration. """ if not os.path.isfile(filepath): raise ValueError( 'Model definition file ({}) was not found.'.format(filepath)) return load_config(filepath, **parameters)
def _load_optimizer(filepath): cfg = load_config(filepath) return get_optimizer(cfg['typename'])(**cfg.get('args', {}))
def _make_agent(config_file): config = (load_config(config_file) if config_file else { 'typename': 'NoOpAgent', 'args': {} }) return get_agent(config['typename'])(**config.get('args', {}))
def create_env(cfg_file): """Load Environment config file and instantiate""" cfg = load_config(cfg_file) env = get_env(cfg['name'])(**cfg['args']) print('\n{}'.format(env)) return env
def _make_optimizer(filepath): cfg = load_config(filepath) return nn.get_optimizer(cfg['typename'])(**cfg['args'])
def _load_agent(config_file_path): config = load_config(config_file_path) return get_agent(config['name'])(**config['args'])
def _load_optimizer(filepath): cfg = load_config(filepath) return nn.fetch_optimizer(cfg['typename'])(**cfg.get('args', {}))