Skip to main content

A collection of Reinforcement Learning algorithms to train autonomous agents in different environments.

Project description

EnvQuest

Train and evaluate your autonomous agents in different environments using a collection of RL algorithms.

Installation

To install the EnvQuest library, use pip install envquest.

Usage

Run a simple gym environment

from envquest import envs, agents

# Instantiate an environment
env = envs.gym.GymEnvironment.from_task("LunarLander-v3")

# Instantiate an agent
agent = agents.generics.RandomAgent(env.observation_space, env.action_space)

# Execute an MDP
timestep = env.reset()

while not timestep.last():
    observation = timestep.observation
    action = agent.act(observation=observation)
    timestep = env.step(action)

# Render the environment
frame = env.render(256, 256)

Usage with metaworld

import metaworld
import random

from envquest import envs

ml1 = metaworld.ML1("basketball-v2")
task = random.choice(ml1.train_tasks)
env = ml1.train_classes["basketball-v2"](render_mode="rgb_array")
env.set_task(task)

env = envs.gym.GymEnvironment.from_env(env)

Train a DQN Agent in a gym environment

First, set up a WandB logging environment

# Install wandb
pip install wandb

# Start a wandb local server
wandb server start

Then, train a DQN agent in a gym's CartPole-v1 environment.

from envquest import arguments, envs, agents, trainers

# Define training arguments
args = arguments.TrainingArguments(
    env=arguments.EnvArguments(task="CartPole-v1"),
    agent=arguments.DQNAgentArguments(),
    logging=arguments.LoggingArguments(save_agent_snapshots=False)
)

# Instantiate an environment
env = envs.gym.GymEnvironment.from_task(task=args.env.task, max_episode_length=args.env.max_episode_length)

# Instantiate a DQN Agent
agent = agents.dqn_agents.DiscreteQNetAgent(
    mem_capacity=args.agent.mem_capacity,
    discount=args.agent.discount,
    n_steps=args.agent.n_steps,
    lr=args.agent.lr,
    tau=args.agent.tau,
    eps_start=args.agent.eps_start,
    eps_end=args.agent.eps_end,
    eps_step_duration=args.agent.eps_step_duration,
    eps_decay=args.agent.eps_decay,
    observation_space=env.observation_space,
    action_space=env.action_space,
)

# Instantiate a trainer
trainer = trainers.td_trainers.TDTrainer(env, agent, args)

# Start training
trainer.train()

Track the performances of your agent on wandb: http://localhost:8080/

Examples

See some examples in the examples folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envquest-0.0.12.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envquest-0.0.12-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file envquest-0.0.12.tar.gz.

File metadata

  • Download URL: envquest-0.0.12.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for envquest-0.0.12.tar.gz
Algorithm Hash digest
SHA256 c3a93327896d52c2901c12a6ac1c357f3f18e80a6f7b75c6347db2dde0d9e778
MD5 ab690fe91db96ddd16d08d7f692c65bb
BLAKE2b-256 337f15439b77eed8167a339e98acf9c5cfc4a25b14cdd1e215355c2eb144762b

See more details on using hashes here.

File details

Details for the file envquest-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: envquest-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for envquest-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9176d8b6915cb3fee1f7315ccae451204b7b40e709331ef964ff211a28e66ae6
MD5 2e6f7deb7fc52555d9a9edcc4b15b5fc
BLAKE2b-256 cfcf5dcc422eddcaf99605f408c38cca4e5cbac332b0c5c3f53c5532a67e37f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page