PPO Agent playing LunarLander-v2
This is a trained model of a PPO agent playing LunarLander-v2 using the stable-baselines3 library
This model is trained with the help of Deep RL Course by HuggingFace
Usage (with Stable-baselines3)
# necessary libraries
import gymnasium as gym
from huggingface_sb3 import load_from_hub, package_to_hub
from huggingface_hub import (
notebook_login,
)
from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_vec_env
from stable_baselines3.common.evaluation import evaluate_policy
from stable_baselines3.common.monitor import Monitor
# Step 1 : Create an environment
env = gym.make("LunarLander-v2")
observation,info = env.reset() # initialize the environment
# Step 2 : Create the model
model = PPO(
policy = "MlpPolicy", # Multiple Layer Perceptron Policy
env = env,
n_steps = 1024,
batch_size = 64,
n_epochs = 5,
gamma = 0.995,
gae_lambda = 0.98,
ent_coef = 0.0001,
clip_range = 0.1,
verbose = 1
)
# Step 3 : Train the model
model.learn(total_timesteps=2500000,progress_bar = True)
# Step 4 : Evaluation
eval_env = Monitor(gym.make("LunarLander-v2"))
mean_reward,std_reward = evaluate_policy(model,eval_env,n_eval_episodes = 10 ,deterministic=True)
print(f"Mean reward : {mean_reward} +/- {std_reward}")
- Downloads last month
- 0
Evaluation results
- mean_reward on LunarLander-v2self-reported264.51 +/- 16.47