DLR-RM / stable-baselines3

PyTorch version of Stable Baselines, reliable implementations of reinforcement learning algorithms.
https://stable-baselines3.readthedocs.io
MIT License
8.74k stars 1.66k forks source link

[Question] About the logger #1997

Open XiaobenLi00 opened 2 weeks ago

XiaobenLi00 commented 2 weeks ago

❓ Question

In the doc https://stable-baselines3.readthedocs.io/en/master/common/logger.html, there is a warning

image

I am wondering that if I a custom logger object like

logger = configure(f'results_{job_data.env}')
model = PPO(job_data.policy, env,  verbose=1,
                    tensorboard_log=f"wandb/{run.id}",
                    learning_rate=job_data.learning_rate, 
                    batch_size=job_data.batch_size, 
                    policy_kwargs=policy_kwargs,
                    gamma=job_data.gamma, **job_data.alg_hyper_params)
...
model.set_logger(logger)
model.learn(
    total_timesteps=config["total_timesteps"],
    callback=callback,
)

How should I set tensorboard_log and verbose? Because I notice that in the code below, the settings is overwritten and no info is logged.

Checklist

araffin commented 1 week ago

why do you need a custom logger in your case? it seems that you just want to change the name, we have tb_log_name parameter (to the learn() method) for that.

Nothing is logged in your case because you didn't specify any logger format... https://github.com/DLR-RM/stable-baselines3/blob/9a3b28bb9f24a1646479500fb23be55ba652a30d/stable_baselines3/common/logger.py#L638

the built-in configure is here: https://github.com/DLR-RM/stable-baselines3/blob/9a3b28bb9f24a1646479500fb23be55ba652a30d/stable_baselines3/common/utils.py#L181-L215