Downloads · 30 days
0
0% of all-time downloads
kaikytoledo/LunarLander
LunarLander is a reinforcement learning model from kaikytoledo. 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
0
0% of all-time downloads
All-time downloads
100
Public
Repo size
284 KB
Likes
0
Public
Click a slice to open those files.
.zip149 KB · 47%
From the Hugging Face model README
This is a trained model of a PPO agent playing LunarLander-v3 using the stable-baselines3 library.
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",
)
...