Downloads · 30 days
3
3% of all-time downloads
JaiSurya/PPO-LunarLander-v2
PPO-LunarLander-v2 is a reinforcement learning model from JaiSurya. 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-v2 using the stable-baselines3 library
Downloads · 30 days
3
3% of all-time downloads
All-time downloads
94
Public
Repo size
560 KB
Likes
1
Public
Click a slice to open those files.
.mp4189 KB · 38%
From the Hugging Face model README
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
# 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}")