Downloads · 30 days
3
9% of all-time downloads
roshana1s/ppo-LunarLander-v3
ppo-LunarLander-v3 is a reinforcement learning model from roshana1s. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for stable-baselines3.
This is a trained model of a PPO agent playing LunarLander-v3 using the stable-baselines3 library.
Downloads · 30 days
3
9% of all-time downloads
All-time downloads
32
Public
Repo size
610 KB
Likes
1
Public
Click a slice to open those files.
.mp4176 KB · 36%
From the Hugging Face model README
This is a trained model of a PPO agent playing LunarLander-v3 using the stable-baselines3 library.
Install the required libraries:
pip install stable-baselines3 huggingface-sb3 "gymnasium[box2d]"
Load the trained PPO agent from the Hugging Face Hub:
import os
import gymnasium as gym
from stable_baselines3 import PPO
from stable_baselines3.common.evaluation import evaluate_policy
from huggingface_sb3 import load_from_hub
# Required by huggingface_sb3 when loading the model
# Only enable this for repositories you trust
os.environ["TRUST_REMOTE_CODE"] = "True"
# Download the trained model
checkpoint = load_from_hub(
repo_id="roshana1s/ppo-LunarLander-v3",
filename="ppo-LunarLander-v3.zip",
)
# Load the PPO model
model = PPO.load(checkpoint)
# Create the LunarLander environment
env = gym.make("LunarLander-v3")
# Evaluate the agent
mean_reward, std_reward = evaluate_policy(
model,
env,
n_eval_episodes=10,
deterministic=True
)
print(f"Mean reward: {mean_reward:.2f} +/- {std_reward:.2f}")
env.close()
env = gym.make("LunarLander-v3", render_mode="human")
obs, info = env.reset()
terminated = False
truncated = False
while not (terminated or truncated):
action, _ = model.predict(obs, deterministic=True)
obs, reward, terminated, truncated, info = env.step(action)
env.close()