def __init__(
        self,
        env_class,
        agent_class,
        network_fn,
        config,
        scope,
        init_hooks,
        compress_episodes,
    ):

        gin.parse_config(config, skip_unknown=True)

        for hook in init_hooks:
            hook()

        import tensorflow as tf
        tf.config.threading.set_inter_op_parallelism_threads(1)
        tf.config.threading.set_intra_op_parallelism_threads(1)

        with gin.config_scope(scope):
            self.env = env_class()
            self.agent = agent_class()
            self._request_handler = core.RequestHandler(network_fn)

        self._compress_episodes = compress_episodes
Пример #2
0
        def __init__(
            self,
            env_class,
            agent_class,
            network_fn,
            model_class,
            model_network_fn,
            config,
            init_hooks,
        ):
            # Limit number of threads used between independent tf.op-s to 1.
            import tensorflow as tf  # pylint: disable=import-outside-toplevel
            tf.config.threading.set_inter_op_parallelism_threads(1)
            tf.config.threading.set_intra_op_parallelism_threads(1)

            gin.parse_config(config, skip_unknown=True)

            for hook in init_hooks:
                hook()

            self.env = env_class()
            self.agent = (agent_class() if model_class is None else
                          agent_class(model_class=model_class))

            # Metrics cause some problems with Ray, so we switch them off,
            # as we don't train any networks inside the worker.
            if network_fn:
                network_fn = functools.partial(network_fn, metrics=None)
            if model_network_fn:
                model_network_fn = functools.partial(model_network_fn,
                                                     metrics=None)
            self._request_handler = core.RequestHandler(
                network_fn, model_network_fn=model_network_fn)
Пример #3
0
    def __init__(self, env_class, agent_class, network_fn, n_envs, output_dir):
        super().__init__(env_class, agent_class, network_fn, n_envs, output_dir)

        def make_env_and_agent():
            env = env_class()
            agent = agent_class()
            return (env, agent)

        self._envs_and_agents = [make_env_and_agent() for _ in range(n_envs)]
        self._request_handler = core.RequestHandler(network_fn)
Пример #4
0
        def __init__(self, env_class, agent_class, network_fn, config):
            # Limit number of threads used between independent tf.op-s to 1.
            import tensorflow as tf  # pylint: disable=import-outside-toplevel
            tf.config.threading.set_inter_op_parallelism_threads(1)
            tf.config.threading.set_intra_op_parallelism_threads(1)

            # TODO(pj): Test that skip_unknown is required!
            gin.parse_config(config, skip_unknown=True)

            self.env = env_class()
            self.agent = agent_class()
            self._request_handler = core.RequestHandler(network_fn)
Пример #5
0
    def __init__(self,
                 env_class,
                 agent_class,
                 network_fn,
                 n_envs,
                 output_dir,
                 model_class=None,
                 model_network_fn=None):
        super().__init__(env_class, agent_class, network_fn, n_envs,
                         output_dir, model_class, model_network_fn)

        def make_env_and_agent():
            env = env_class()
            agent = (agent_class() if model_class is None else agent_class(
                model_class=model_class))
            return env, agent

        self._envs_and_agents = [make_env_and_agent() for _ in range(n_envs)]
        self._request_handler = core.RequestHandler(network_fn,
                                                    model_network_fn)