Skip to content

Conversation

Zeyi-Lin
Copy link
Member

Description

需要安装的环境:

pip install gymnasium stable_baselines3

测试代码:

import swanlab
import gymnasium as gym
from stable_baselines3 import PPO
from stable_baselines3.common.monitor import Monitor
from stable_baselines3.common.vec_env import DummyVecEnv
from swanlab.integration.sb3 import SwanLabCallback

config = {
    "policy_type": "MlpPolicy",
    "total_timesteps": 25000,
    "env_name": "CartPole-v1",
}


def make_env():
    env = gym.make(config["env_name"], render_mode="rgb_array")
    env = Monitor(env)
    return env


env = DummyVecEnv([make_env])
model = PPO(
    config["policy_type"],
    env,
    verbose=1,
)

model.learn(
    total_timesteps=config["total_timesteps"],
    callback=SwanLabCallback(
        project="PPO",
        experiment_name="MlpPolicy",
        verbose=2,
    ),
)

swanlab.finish()

Closes: #563

@Zeyi-Lin Zeyi-Lin requested a review from SAKURA-CAT May 23, 2024 12:35
@Zeyi-Lin Zeyi-Lin self-assigned this May 23, 2024
@Zeyi-Lin Zeyi-Lin merged commit 7363ba5 into main May 23, 2024
@SAKURA-CAT
Copy link
Member

SAKURA-CAT commented May 23, 2024

应该把一些集成脚本写入test文件夹,并附上必要的安装脚本,方便复现。

@SAKURA-CAT SAKURA-CAT deleted the feat/integration-sb3 branch May 23, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQUEST] 集成-StableBaseline3

2 participants