Acme Reinforcement Learning Framework

repository·master·Indexed 26 days ago

https://github.com/google-deepmind/acme

A research framework for reinforcement learning (RL) providing modular building blocks, reference implementations, and strong baselines. Acme supports scaling from single-stream to distributed environments and includes agents for continuous control (D4PG, MPO), discrete actions (DQN), offline learning (BC, BCQ), and from-demonstration tasks (DQfD). It integrates with dm_env, OpenAI Gym, and the Behaviour Suite (bsuite), with backend support for JAX and TensorFlow.

Tokens
7.5K
Snippets
20
Records
41
Agent score
88%

What's inside Acme

  1. Overview of Acme Reinforcement Learning Framework

    master

    Acme is a reinforcement learning (RL) research framework composed of modular building blocks. It is designed to provide:

    • Reference Implementations: High-quality implementations of RL algorithms.
    • Strong Baselines: Reliable performance baselines for algorithm comparison.
    • Research Flexibility: Simple and flexible components that can be used as starting points for novel research.
    • Scalability: Agents designed to run at multiple scales, ranging from single-stream to distributed environments.
  2. Integrate dm_env environments with Acme

    master

    Acme is designed to work with environments implementing the dm_env interface. This provides a standard API for actions and observations. To obtain a full environment spec compatible with Acme agents, use acme.make_environment_spec(environment).

    Acme provides several wrappers in acme.wrappers to modify environment behavior:

    • SinglePrecisionWrapper: Converts float and int components to single-precision.
    • AtariWrapper: Implements standard ALE Atari modifications (from the Nature Atari paper).
    • acme.wrappers.gym_wrapper.GymWrapper: Allows interaction with OpenAI Gym environments.
    • acme.wrappers.gym_wrapper.AtariGymWrapper: A Gym wrapper that exposes a lives count observation.
  3. Run Continuous Control agents (D4PG and MPO)

    master

    Acme provides agents for continuous control tasks. Note that many examples using the DeepMind Control Suite require a MuJoCo license.

    Available agents include:

    • D4PG: A deterministic policy gradient agent with a deterministic policy and a distributional critic. It can run on DeepMind Control Suite or OpenAI Gym (defaults to the "half cheetah" environment).
    • MPO: A maximum-a-posterior policy optimization agent combining a distributional critic and a stochastic policy.
  4. Format data for Acme learners

    master
    Acme learners consume dataset iterators (typically tf.Dataset instances). These iterators should yield either transition tuples or sequences of (state, action, reward, etc.) tuples. If your data format differs, you will need to write an adaptor to match the expected input of your specific agent.
  5. Make environments compatible with Acme

    master

    Acme agents are designed to work with environments that implement the dm_env environment interface. If your environment uses a different interface, you must write a wrapper to make it conform to dm_env.

    For OpenAI Gym environments, you can use the acme.wrappers.gym_wrapper module to facilitate interaction.

  6. Implement an environment loop with Acme Actors

    master

    To run an Acme agent, you connect an actor instance to an environment that conforms to the DeepMind Environment API. The interaction follows a standard reinforcement learning loop where the actor uses select_action to choose actions, observe to record environment transitions, and update to perform learning steps.

    Note: While some older implementations use observe_last, the standard pattern is to use observe_first for the initial state and observe for subsequent steps.

    while True:
      # Make an initial observation.
      step = environment.reset()
      actor.observe_first(step.observation)
    
      while not step.last():
        # Evaluate the policy and take a step in the environment.
        action = actor.select_action(step.observation)
        step = environment.step(action)
    
        # Make an observation and update the actor.
        actor.observe(action, next_step=step)
        actor.update()