Reinforcement Learning
stable-baselines3
LunarLander-v2
deep-reinforcement-learning
Eval Results (legacy)
Instructions to use kaikytoledo/LunarLander with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use kaikytoledo/LunarLander with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="kaikytoledo/LunarLander", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
PPO Agent playing LunarLander-v3
This is a trained model of a PPO agent playing LunarLander-v3 using the stable-baselines3 library.
Usage (with Stable-baselines3)
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
import gymnasium as gym
from stable_baselines3.common.vec_env import DummyVecEnv
env = make_vec_env("LunarLander-v3", 4)
print(f"Espaço Observado {env.observation_space.shape}")
print(f"Amostras {env.observation_space.sample()}")
print(f"Ações: {env.action_space.n}")
model = PPO(
policy="MlpPolicy",
env=env,
n_steps=1024,
batch_size=64,
n_epochs=2,
gamma=0.999,
gae_lambda=0.98,
ent_coef=0.01,
verbose=1)
model.learn(1500000)
eval_env = make_vec_env("LunarLander-v3", 4)
mean_reward, std_reward = evaluate_policy(model,eval_env,n_eval_episodes=10,deterministic=True)
print(f"mean_reward={mean_reward:.2f} +/- {std_reward:.2f}")
model_name = "ppo-LunarLander-v3"
model.save(model_name)
package_to_hub(
model=model, # Our trained model
model_name=model_name, # The name of our trained model
model_architecture="PPO", # The model architecture we used: in our case PPO
env_id='LunarLander-v3', # Name of the environment
eval_env=DummyVecEnv([lambda: Monitor(gym.make("LunarLander-v3", render_mode="rgb_array"))]), # Evaluation Environment
repo_id="kaikytoledo/LunarLander", # id of the model repository from the Hugging Face Hub (repo_id = {organization}/{repo_name} for instance ThomasSimonini/ppo-LunarLander-v2
commit_message="Modelo LunarLander",
)
...
- Downloads last month
- 3
Evaluation results
- mean_reward on LunarLander-v3self-reported253.40 +/- 17.82