D4RL Documentation
repository·master·Indexed 23 days ago
https://github.com/farama-foundation/d4rlAn open-source benchmark for offline reinforcement learning providing standardized environments and datasets. D4RL uses the OpenAI Gym API for environment creation and provides tools for dataset retrieval, score normalization, and support for platforms like the Adroit manipulation platform. Note: D4RL is being phased out in favor of Gymnasium and Minari.
What's inside D4RL
- The Adroit manipulation platform is a reconfigurable, tendon-driven, pneumatically-actuated system designed for studying dynamic dexterous manipulation. In this repository, it is provided as a MuJoCo model. The system features 28 degrees of freedom (DoF), consisting of a 24 DoF ShadowHand and a 4 DoF arm.
Install D4RL
masterYou can install D4RL by cloning the repository or via pip directly from GitHub.
Option 1: Clone and install in editable mode
git clone https://github.com/Farama-Foundation/d4rl.git cd d4rl pip install -e .Option 2: Install via pip
pip install git+https://github.com/Farama-Foundation/d4rl@master#egg=d4rlDependencies:
- MuJoCo: Required for control environments. You may need to follow
mujoco_pysetup instructions and obtain a license. - CARLA: Requires additional setup instructions found in the project wiki.
- Flow: Requires the SUMO simulator and adding the flow repository to your
PYTHONPATH.
git clone https://github.com/Farama-Foundation/d4rl.git cd d4rl pip install -e . # OR pip install git+https://github.com/Farama-Foundation/d4rl@master#egg=d4rl- MuJoCo: Required for control environments. You may need to follow
Migrate from D4RL to Gymnasium and Minari
masterIMPORTANT NOTICE
D4RL is being phased out. For active development and bug fixes, please migrate to the following libraries:
- Environments: Use Gymnasium, MiniGrid, or Gymnasium-Robotics.
- Datasets: Use Minari for offline RL datasets.
New development continues exclusively in these libraries.
Configure D4RL dataset storage directory
masterBy default, datasets are downloaded to
~/.d4rl/datasetswhenget_dataset()is called.You can change this behavior in two ways:
- Set the
$D4RL_DATASET_DIRenvironment variable to your preferred path. - Pass the dataset filepath directly into the
get_dataset()method.
- Set the
Create environments and access datasets in D4RL
masterD4RL uses the OpenAI Gym API. Environments are created using
gym.make(). Note that you mustimport d4rlto register the environments.Each task is associated with a fixed offline dataset. You can retrieve this dataset using
env.get_dataset().Dataset Dictionary Keys:
observations: N x observation_dim array.actions: N x action_dim array.rewards: N dimensional array.terminals: N dimensional array (true on termination conditions like falling over).timeouts: N dimensional array (true on reaching max episode length).infos: Task-specific debugging information.
For Q-learning algorithms, use
d4rl.qlearning_dataset(env)to get a version that includes anext_observationskey.import gym import d4rl # Required to register environments # Create the environment env = gym.make('maze2d-umaze-v1') # Standard Gym interface env.reset() env.step(env.action_space.sample()) # Get standard dataset dataset = env.get_dataset() print(dataset['observations']) # Get dataset formatted for Q-learning (includes next_observations) dataset = d4rl.qlearning_dataset(env)Normalize scores using env.get_normalized_score()
masterTo compute a normalized score for an episode, use
env.get_normalized_score(returns). Thereturnsargument should be the undiscounted total sum of rewards accumulated during an episode.Reference values for min and max scores are located in
d4rl/infos.py.