XLand-MiniGrid

Dec 22, 2020 | Data Science

PyPI Version Shield Badge Badge Xiv Badge Twitter Badge Open In Colab

![Img](figures/readme-main-img.png)

Introduction

XLand-MiniGrid is a robust suite of tools and grid-world environments crafted for meta-reinforcement learning research. It draws inspiration from the profound diversity of XLand and the minimalism of MiniGrid. With its foundation in JAX, XLand-MiniGrid is designed to be highly scalable, opening the door for large-scale experimentation with limited resources.

Features

  • Flexible system of rules and goals allowing for diverse task distributions
  • Simple extensibility, with numerous examples from original MiniGrid
  • Compatible with all JAX transformations, working efficiently on CPU, GPU, or TPU
  • Ability to run up to $2^{16}$ parallel environments and achieve millions of steps per second on a single GPU
  • Powerful baselines in the PureJaxRL style, facilitating rapid prototyping

How to Install XLand-MiniGrid

Installing XLand-MiniGrid can be done effortlessly via PyPI or GitHub:

pip install xminigrid
# or from GitHub directly
pip install git+https://github.com/corl-team/xland-minigrid.git

For a development version, clone the repository:

git clone git@github.com:corl-team/xland-minigrid.git
cd xland-minigrid
# add dependencies
pip install -e .[dev,baselines]

Remember, JAX installation varies by hardware accelerator. Check the official installation guide for specifics.

Basic Usage

The XLand-MiniGrid interface is similar to other JAX-based environments. Let’s imagine our environment is like a robot navigating through a grid-filled maze. Just like the robot uses its sensors to understand surroundings and act accordingly, you will use the API to interact with the environment.

Here’s how to get started:

import jax
import xminigrid
from xminigrid.wrappers import GymAutoResetWrapper
from xminigrid.experimental.img_obs import RGBImgObservationWrapper

key = jax.random.key(0)
reset_key, ruleset_key = jax.random.split(key)

# List available benchmarks
xminigrid.registered_benchmarks()

# Load a benchmark
benchmark = xminigrid.load_benchmark(name='trivial-1m')

# Sample a ruleset
ruleset = benchmark.sample_ruleset(ruleset_key)

# Create the environment
env, env_params = xminigrid.make('XLand-MiniGrid-R9-25x25')
env_params = env_params.replace(ruleset=ruleset)

# Set up wrappers
env = GymAutoResetWrapper(env)
env = RGBImgObservationWrapper(env)

# Step through the environment
timestep = jax.jit(env.reset)(env_params, reset_key)
timestep = jax.jit(env.step)(env_params, timestep, action=0)

# Render the current state
env.render(env_params, timestep)

Troubleshooting Tips

Facing any issues? Here are a few troubleshooting ideas:

  • Ensure that all dependencies are correctly installed, including the right version of JAX.
  • If you’re experiencing errors related to environment loading, double-check the names and parameters you’re using.
  • Utilize the debug options provided in the training scripts for detailed error information.
  • For quick iterations, try using the ‘trivial-1m’ benchmark as a testing ground.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox